History

net: Update API for VF vlan protocol 802.1ad support

Introduce new rtnl UAPI that exposes a list of vlans per VF, giving the ability for user-space application to specify it for the VF, as an option to support 802.1ad. We adjusted IP Link tool to support this option. For future use cases, the new UAPI supports multiple vlans. For now we limit the list size to a single vlan in kernel. Add IFLA_VF_VLAN_LIST in addition to IFLA_VF_VLAN to keep backward compatibility with older versions of IP Link tool. Add a vlan protocol parameter to the ndo_set_vf_vlan callback. We kept 802.1Q as the drivers' default vlan protocol. Suitable ip link tool command examples: Set vf vlan protocol 802.1ad: ip link set eth0 vf 1 vlan 100 proto 802.1ad Set vf to VST (802.1Q) mode: ip link set eth0 vf 1 vlan 100 proto 802.1Q Or by omitting the new parameter ip link set eth0 vf 1 vlan 100

Moshe Shemesh committed 10 years ago

Commit 79aab091 parent 0815fe323 files · +161 −42Browse files

Unified · Split

23 files
  1. drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h +2 −1
  2. drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c +7 −2
  3. drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c +5 −1
  4. drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.h +1 −1
  5. drivers/net/ethernet/emulex/benet/be_main.c +5 −1
  6. drivers/net/ethernet/intel/fm10k/fm10k.h +1 −1
  7. drivers/net/ethernet/intel/fm10k/fm10k_iov.c +5 −1
  8. drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +9 −2
  9. drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h +2 −2
  10. drivers/net/ethernet/intel/igb/igb_main.c +6 −3
  11. drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c +4 −1
  12. drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.h +1 −1
  13. drivers/net/ethernet/mellanox/mlx4/en_netdev.c +5 −1
  14. drivers/net/ethernet/mellanox/mlx5/core/en_main.c +5 −1
  15. drivers/net/ethernet/qlogic/qede/qede_main.c +5 −1
  16. drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov.h +1 −1
  17. drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_pf.c +4 −1
  18. drivers/net/ethernet/sfc/sriov.c +4 −1
  19. drivers/net/ethernet/sfc/sriov.h +1 −1
  20. include/linux/if_link.h +1 −0
  21. include/linux/netdevice.h +4 −2
  22. include/uapi/linux/if_link.h +18 −1
  23. net/core/rtnetlink.c +65 −15
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h+2−1
@@ -492,7 +492,8 @@ int __bnx2x_setup_tc(struct net_device *dev, u32 handle, __be16 proto, · 491 unmodified lines
492492 int bnx2x_get_vf_config(struct net_device *dev, int vf,
493493 struct ifla_vf_info *ivi);
494494 int bnx2x_set_vf_mac(struct net_device *dev, int queue, u8 *mac);
495−int bnx2x_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan, u8 qos);
495+int bnx2x_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan, u8 qos,
496+ __be16 vlan_proto);
496497
497498 /* select_queue callback */
498499 u16 bnx2x_select_queue(struct net_device *dev, struct sk_buff *skb,
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c+7−2
@@ -2521,7 +2521,8 @@ void bnx2x_pf_set_vfs_vlan(struct bnx2x *bp) · 2520 unmodified lines
25212521 for_each_vf(bp, vfidx) {
25222522 bulletin = BP_VF_BULLETIN(bp, vfidx);
25232523 if (bulletin->valid_bitmap & (1 << VLAN_VALID))
2524− bnx2x_set_vf_vlan(bp->dev, vfidx, bulletin->vlan, 0);
2524+ bnx2x_set_vf_vlan(bp->dev, vfidx, bulletin->vlan, 0,
2525+ htons(ETH_P_8021Q));
25252526 }
25262527 }
25272528
@@ -2781,7 +2782,8 @@ static int bnx2x_set_vf_vlan_filter(struct bnx2x *bp, struct bnx2x_virtf *vf, · 253 unmodified lines
27812782 return 0;
27822783 }
27832784
2784−int bnx2x_set_vf_vlan(struct net_device *dev, int vfidx, u16 vlan, u8 qos)
2785+int bnx2x_set_vf_vlan(struct net_device *dev, int vfidx, u16 vlan, u8 qos,
2786+ __be16 vlan_proto)
27852787 {
27862788 struct pf_vf_bulletin_content *bulletin = NULL;
27872789 struct bnx2x *bp = netdev_priv(dev);
@@ -2796,6 +2798,9 @@ int bnx2x_set_vf_vlan(struct net_device *dev, int vfidx, u16 vlan, u8 qos) · 8 unmodified lines
27962798 return -EINVAL;
27972799 }
27982800
2801+ if (vlan_proto != htons(ETH_P_8021Q))
2802+ return -EPROTONOSUPPORT;
2803+
27992804 DP(BNX2X_MSG_IOV, "configuring VF %d with VLAN %d qos %d\n",
28002805 vfidx, vlan, 0);
28012806
drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c+5−1
@@ -174,7 +174,8 @@ int bnxt_set_vf_mac(struct net_device *dev, int vf_id, u8 *mac) · 173 unmodified lines
174174 return hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
175175 }
176176
177−int bnxt_set_vf_vlan(struct net_device *dev, int vf_id, u16 vlan_id, u8 qos)
177+int bnxt_set_vf_vlan(struct net_device *dev, int vf_id, u16 vlan_id, u8 qos,
178+ __be16 vlan_proto)
178179 {
179180 struct hwrm_func_cfg_input req = {0};
180181 struct bnxt *bp = netdev_priv(dev);
@@ -185,6 +186,9 @@ int bnxt_set_vf_vlan(struct net_device *dev, int vf_id, u16 vlan_id, u8 qos) · 4 unmodified lines
185186 if (bp->hwrm_spec_code < 0x10201)
186187 return -ENOTSUPP;
187188
189+ if (vlan_proto != htons(ETH_P_8021Q))
190+ return -EPROTONOSUPPORT;
191+
188192 rc = bnxt_vf_ndo_prep(bp, vf_id);
189193 if (rc)
190194 return rc;
drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.h+1−1
@@ -12,7 +12,7 @@ · 11 unmodified lines
1212
1313 int bnxt_get_vf_config(struct net_device *, int, struct ifla_vf_info *);
1414 int bnxt_set_vf_mac(struct net_device *, int, u8 *);
15−int bnxt_set_vf_vlan(struct net_device *, int, u16, u8);
15+int bnxt_set_vf_vlan(struct net_device *, int, u16, u8, __be16);
1616 int bnxt_set_vf_bw(struct net_device *, int, int, int);
1717 int bnxt_set_vf_link_state(struct net_device *, int, int);
1818 int bnxt_set_vf_spoofchk(struct net_device *, int, bool);
drivers/net/ethernet/emulex/benet/be_main.c+5−1
@@ -1895,7 +1895,8 @@ static int be_clear_vf_tvt(struct be_adapter *adapter, int vf) · 1894 unmodified lines
18951895 return 0;
18961896 }
18971897
1898−static int be_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan, u8 qos)
1898+static int be_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan, u8 qos,
1899+ __be16 vlan_proto)
18991900 {
19001901 struct be_adapter *adapter = netdev_priv(netdev);
19011902 struct be_vf_cfg *vf_cfg = &adapter->vf_cfg[vf];
@@ -1907,6 +1908,9 @@ static int be_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan, u8 qos) · 5 unmodified lines
19071908 if (vf >= adapter->num_vfs || vlan > 4095 || qos > 7)
19081909 return -EINVAL;
19091910
1911+ if (vlan_proto != htons(ETH_P_8021Q))
1912+ return -EPROTONOSUPPORT;
1913+
19101914 if (vlan || qos) {
19111915 vlan |= qos << VLAN_PRIO_SHIFT;
19121916 status = be_set_vf_tvt(adapter, vf, vlan);
drivers/net/ethernet/intel/fm10k/fm10k.h+1−1
@@ -507,7 +507,7 @@ int fm10k_iov_configure(struct pci_dev *pdev, int num_vfs); · 506 unmodified lines
507507 s32 fm10k_iov_update_pvid(struct fm10k_intfc *interface, u16 glort, u16 pvid);
508508 int fm10k_ndo_set_vf_mac(struct net_device *netdev, int vf_idx, u8 *mac);
509509 int fm10k_ndo_set_vf_vlan(struct net_device *netdev,
510− int vf_idx, u16 vid, u8 qos);
510+ int vf_idx, u16 vid, u8 qos, __be16 vlan_proto);
511511 int fm10k_ndo_set_vf_bw(struct net_device *netdev, int vf_idx, int rate,
512512 int unused);
513513 int fm10k_ndo_get_vf_config(struct net_device *netdev,
drivers/net/ethernet/intel/fm10k/fm10k_iov.c+5−1
@@ -445,7 +445,7 @@ int fm10k_ndo_set_vf_mac(struct net_device *netdev, int vf_idx, u8 *mac) · 444 unmodified lines
445445 }
446446
447447 int fm10k_ndo_set_vf_vlan(struct net_device *netdev, int vf_idx, u16 vid,
448− u8 qos)
448+ u8 qos, __be16 vlan_proto)
449449 {
450450 struct fm10k_intfc *interface = netdev_priv(netdev);
451451 struct fm10k_iov_data *iov_data = interface->iov_data;
@@ -460,6 +460,10 @@ int fm10k_ndo_set_vf_vlan(struct net_device *netdev, int vf_idx, u16 vid, · 8 unmodified lines
460460 if (qos || (vid > (VLAN_VID_MASK - 1)))
461461 return -EINVAL;
462462
463+ /* VF VLAN Protocol part to default is unsupported */
464+ if (vlan_proto != htons(ETH_P_8021Q))
465+ return -EPROTONOSUPPORT;
466+
463467 vf_info = &iov_data->vf_info[vf_idx];
464468
465469 /* exit if there is nothing to do */
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c+9−2
@@ -2747,11 +2747,12 @@ error_param: · 2746 unmodified lines
27472747 * @vf_id: VF identifier
27482748 * @vlan_id: mac address
27492749 * @qos: priority setting
2750+ * @vlan_proto: vlan protocol
27502751 *
27512752 * program VF vlan id and/or qos
27522753 **/
2753−int i40e_ndo_set_vf_port_vlan(struct net_device *netdev,
2754− int vf_id, u16 vlan_id, u8 qos)
2754+int i40e_ndo_set_vf_port_vlan(struct net_device *netdev, int vf_id,
2755+ u16 vlan_id, u8 qos, __be16 vlan_proto)
27552756 {
27562757 u16 vlanprio = vlan_id | (qos << I40E_VLAN_PRIORITY_SHIFT);
27572758 struct i40e_netdev_priv *np = netdev_priv(netdev);
@@ -2774,6 +2775,12 @@ int i40e_ndo_set_vf_port_vlan(struct net_device *netdev, · 16 unmodified lines
27742775 goto error_pvid;
27752776 }
27762777
2778+ if (vlan_proto != htons(ETH_P_8021Q)) {
2779+ dev_err(&pf->pdev->dev, "VF VLAN protocol is not supported\n");
2780+ ret = -EPROTONOSUPPORT;
2781+ goto error_pvid;
2782+ }
2783+
27772784 vf = &(pf->vf[vf_id]);
27782785 vsi = pf->vsi[vf->lan_vsi_idx];
27792786 if (!test_bit(I40E_VF_STAT_INIT, &vf->vf_states)) {
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h+2−2
@@ -129,8 +129,8 @@ void i40e_vc_notify_vf_reset(struct i40e_vf *vf); · 128 unmodified lines
129129
130130 /* VF configuration related iplink handlers */
131131 int i40e_ndo_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac);
132−int i40e_ndo_set_vf_port_vlan(struct net_device *netdev,
133− int vf_id, u16 vlan_id, u8 qos);
132+int i40e_ndo_set_vf_port_vlan(struct net_device *netdev, int vf_id,
133+ u16 vlan_id, u8 qos, __be16 vlan_proto);
134134 int i40e_ndo_set_vf_bw(struct net_device *netdev, int vf_id, int min_tx_rate,
135135 int max_tx_rate);
136136 int i40e_ndo_set_vf_trust(struct net_device *netdev, int vf_id, bool setting);
drivers/net/ethernet/intel/igb/igb_main.c+6−3
@@ -169,7 +169,7 @@ static int igb_set_vf_mac(struct igb_adapter *, int, unsigned char *); · 168 unmodified lines
169169 static void igb_restore_vf_multicasts(struct igb_adapter *adapter);
170170 static int igb_ndo_set_vf_mac(struct net_device *netdev, int vf, u8 *mac);
171171 static int igb_ndo_set_vf_vlan(struct net_device *netdev,
172− int vf, u16 vlan, u8 qos);
172+ int vf, u16 vlan, u8 qos, __be16 vlan_proto);
173173 static int igb_ndo_set_vf_bw(struct net_device *, int, int, int);
174174 static int igb_ndo_set_vf_spoofchk(struct net_device *netdev, int vf,
175175 bool setting);
@@ -6222,14 +6222,17 @@ static int igb_disable_port_vlan(struct igb_adapter *adapter, int vf) · 6046 unmodified lines
62226222 return 0;
62236223 }
62246224
6225−static int igb_ndo_set_vf_vlan(struct net_device *netdev,
6226− int vf, u16 vlan, u8 qos)
6225+static int igb_ndo_set_vf_vlan(struct net_device *netdev, int vf,
6226+ u16 vlan, u8 qos, __be16 vlan_proto)
62276227 {
62286228 struct igb_adapter *adapter = netdev_priv(netdev);
62296229
62306230 if ((vf >= adapter->vfs_allocated_count) || (vlan > 4095) || (qos > 7))
62316231 return -EINVAL;
62326232
6233+ if (vlan_proto != htons(ETH_P_8021Q))
6234+ return -EPROTONOSUPPORT;
6235+
62336236 return (vlan || qos) ? igb_enable_port_vlan(adapter, vf, vlan, qos) :
62346237 igb_disable_port_vlan(adapter, vf);
62356238 }
drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c+4−1
@@ -1354,13 +1354,16 @@ static int ixgbe_disable_port_vlan(struct ixgbe_adapter *adapter, int vf) · 1353 unmodified lines
13541354 return err;
13551355 }
13561356
1357−int ixgbe_ndo_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan, u8 qos)
1357+int ixgbe_ndo_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan,
1358+ u8 qos, __be16 vlan_proto)
13581359 {
13591360 int err = 0;
13601361 struct ixgbe_adapter *adapter = netdev_priv(netdev);
13611362
13621363 if ((vf >= adapter->num_vfs) || (vlan > 4095) || (qos > 7))
13631364 return -EINVAL;
1365+ if (vlan_proto != htons(ETH_P_8021Q))
1366+ return -EPROTONOSUPPORT;
13641367 if (vlan || qos) {
13651368 /* Check if there is already a port VLAN set, if so
13661369 * we have to delete the old one first before we
drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.h+1−1
@@ -43,7 +43,7 @@ void ixgbe_disable_tx_rx(struct ixgbe_adapter *adapter); · 42 unmodified lines
4343 void ixgbe_ping_all_vfs(struct ixgbe_adapter *adapter);
4444 int ixgbe_ndo_set_vf_mac(struct net_device *netdev, int queue, u8 *mac);
4545 int ixgbe_ndo_set_vf_vlan(struct net_device *netdev, int queue, u16 vlan,
46− u8 qos);
46+ u8 qos, __be16 vlan_proto);
4747 int ixgbe_link_mbps(struct ixgbe_adapter *adapter);
4848 int ixgbe_ndo_set_vf_bw(struct net_device *netdev, int vf, int min_tx_rate,
4949 int max_tx_rate);
drivers/net/ethernet/mellanox/mlx4/en_netdev.c+5−1
@@ -2400,11 +2400,15 @@ static int mlx4_en_set_vf_mac(struct net_device *dev, int queue, u8 *mac) · 2399 unmodified lines
24002400 return mlx4_set_vf_mac(mdev->dev, en_priv->port, queue, mac_u64);
24012401 }
24022402
2403−static int mlx4_en_set_vf_vlan(struct net_device *dev, int vf, u16 vlan, u8 qos)
2403+static int mlx4_en_set_vf_vlan(struct net_device *dev, int vf, u16 vlan, u8 qos,
2404+ __be16 vlan_proto)
24042405 {
24052406 struct mlx4_en_priv *en_priv = netdev_priv(dev);
24062407 struct mlx4_en_dev *mdev = en_priv->mdev;
24072408
2409+ if (vlan_proto != htons(ETH_P_8021Q))
2410+ return -EPROTONOSUPPORT;
2411+
24082412 return mlx4_set_vf_vlan(mdev->dev, en_priv->port, vf, vlan, qos);
24092413 }
24102414
drivers/net/ethernet/mellanox/mlx5/core/en_main.c+5−1
@@ -2917,11 +2917,15 @@ static int mlx5e_set_vf_mac(struct net_device *dev, int vf, u8 *mac) · 2916 unmodified lines
29172917 return mlx5_eswitch_set_vport_mac(mdev->priv.eswitch, vf + 1, mac);
29182918 }
29192919
2920−static int mlx5e_set_vf_vlan(struct net_device *dev, int vf, u16 vlan, u8 qos)
2920+static int mlx5e_set_vf_vlan(struct net_device *dev, int vf, u16 vlan, u8 qos,
2921+ __be16 vlan_proto)
29212922 {
29222923 struct mlx5e_priv *priv = netdev_priv(dev);
29232924 struct mlx5_core_dev *mdev = priv->mdev;
29242925
2926+ if (vlan_proto != htons(ETH_P_8021Q))
2927+ return -EPROTONOSUPPORT;
2928+
29252929 return mlx5_eswitch_set_vport_vlan(mdev->priv.eswitch, vf + 1,
29262930 vlan, qos);
29272931 }
drivers/net/ethernet/qlogic/qede/qede_main.c+5−1
@@ -100,7 +100,8 @@ static int qede_alloc_rx_buffer(struct qede_dev *edev, · 99 unmodified lines
100100 static void qede_link_update(void *dev, struct qed_link_output *link);
101101
102102 #ifdef CONFIG_QED_SRIOV
103−static int qede_set_vf_vlan(struct net_device *ndev, int vf, u16 vlan, u8 qos)
103+static int qede_set_vf_vlan(struct net_device *ndev, int vf, u16 vlan, u8 qos,
104+ __be16 vlan_proto)
104105 {
105106 struct qede_dev *edev = netdev_priv(ndev);
106107
@@ -109,6 +110,9 @@ static int qede_set_vf_vlan(struct net_device *ndev, int vf, u16 vlan, u8 qos) · 2 unmodified lines
109110 return -EINVAL;
110111 }
111112
113+ if (vlan_proto != htons(ETH_P_8021Q))
114+ return -EPROTONOSUPPORT;
115+
112116 DP_VERBOSE(edev, QED_MSG_IOV, "Setting Vlan 0x%04x to VF [%d]\n",
113117 vlan, vf);
114118
drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov.h+1−1
@@ -238,7 +238,7 @@ int qlcnic_sriov_set_vf_mac(struct net_device *, int, u8 *); · 237 unmodified lines
238238 int qlcnic_sriov_set_vf_tx_rate(struct net_device *, int, int, int);
239239 int qlcnic_sriov_get_vf_config(struct net_device *, int ,
240240 struct ifla_vf_info *);
241−int qlcnic_sriov_set_vf_vlan(struct net_device *, int, u16, u8);
241+int qlcnic_sriov_set_vf_vlan(struct net_device *, int, u16, u8, __be16);
242242 int qlcnic_sriov_set_vf_spoofchk(struct net_device *, int, bool);
243243 #else
244244 static inline void qlcnic_sriov_pf_disable(struct qlcnic_adapter *adapter) {}
drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_pf.c+4−1
@@ -1915,7 +1915,7 @@ int qlcnic_sriov_set_vf_tx_rate(struct net_device *netdev, int vf, · 1914 unmodified lines
19151915 }
19161916
19171917 int qlcnic_sriov_set_vf_vlan(struct net_device *netdev, int vf,
1918− u16 vlan, u8 qos)
1918+ u16 vlan, u8 qos, __be16 vlan_proto)
19191919 {
19201920 struct qlcnic_adapter *adapter = netdev_priv(netdev);
19211921 struct qlcnic_sriov *sriov = adapter->ahw->sriov;
@@ -1928,6 +1928,9 @@ int qlcnic_sriov_set_vf_vlan(struct net_device *netdev, int vf, · 6 unmodified lines
19281928 if (vf >= sriov->num_vfs || qos > 7)
19291929 return -EINVAL;
19301930
1931+ if (vlan_proto != htons(ETH_P_8021Q))
1932+ return -EPROTONOSUPPORT;
1933+
19311934 if (vlan > MAX_VLAN_ID) {
19321935 netdev_err(netdev,
19331936 "Invalid VLAN ID, allowed range is [0 - %d]\n",
drivers/net/ethernet/sfc/sriov.c+4−1
@@ -22,7 +22,7 @@ int efx_sriov_set_vf_mac(struct net_device *net_dev, int vf_i, u8 *mac) · 21 unmodified lines
2222 }
2323
2424 int efx_sriov_set_vf_vlan(struct net_device *net_dev, int vf_i, u16 vlan,
25− u8 qos)
25+ u8 qos, __be16 vlan_proto)
2626 {
2727 struct efx_nic *efx = netdev_priv(net_dev);
2828
@@ -31,6 +31,9 @@ int efx_sriov_set_vf_vlan(struct net_device *net_dev, int vf_i, u16 vlan, · 2 unmodified lines
3131 (qos & ~(VLAN_PRIO_MASK >> VLAN_PRIO_SHIFT)))
3232 return -EINVAL;
3333
34+ if (vlan_proto != htons(ETH_P_8021Q))
35+ return -EPROTONOSUPPORT;
36+
3437 return efx->type->sriov_set_vf_vlan(efx, vf_i, vlan, qos);
3538 } else {
3639 return -EOPNOTSUPP;
drivers/net/ethernet/sfc/sriov.h+1−1
@@ -16,7 +16,7 @@ · 15 unmodified lines
1616
1717 int efx_sriov_set_vf_mac(struct net_device *net_dev, int vf_i, u8 *mac);
1818 int efx_sriov_set_vf_vlan(struct net_device *net_dev, int vf_i, u16 vlan,
19− u8 qos);
19+ u8 qos, __be16 vlan_proto);
2020 int efx_sriov_set_vf_spoofchk(struct net_device *net_dev, int vf_i,
2121 bool spoofchk);
2222 int efx_sriov_get_vf_config(struct net_device *net_dev, int vf_i,
include/linux/if_link.h+1−0
@@ -25,5 +25,6 @@ struct ifla_vf_info { · 24 unmodified lines
2525 __u32 max_tx_rate;
2626 __u32 rss_query_en;
2727 __u32 trusted;
28+ __be16 vlan_proto;
2829 };
2930 #endif /* _LINUX_IF_LINK_H */
include/linux/netdevice.h+4−2
@@ -946,7 +946,8 @@ struct netdev_xdp { · 945 unmodified lines
946946 *
947947 * SR-IOV management functions.
948948 * int (*ndo_set_vf_mac)(struct net_device *dev, int vf, u8* mac);
949− * int (*ndo_set_vf_vlan)(struct net_device *dev, int vf, u16 vlan, u8 qos);
949+ * int (*ndo_set_vf_vlan)(struct net_device *dev, int vf, u16 vlan,
950+ * u8 qos, __be16 proto);
950951 * int (*ndo_set_vf_rate)(struct net_device *dev, int vf, int min_tx_rate,
951952 * int max_tx_rate);
952953 * int (*ndo_set_vf_spoofchk)(struct net_device *dev, int vf, bool setting);
@@ -1187,7 +1188,8 @@ struct net_device_ops { · 234 unmodified lines
11871188 int (*ndo_set_vf_mac)(struct net_device *dev,
11881189 int queue, u8 *mac);
11891190 int (*ndo_set_vf_vlan)(struct net_device *dev,
1190− int queue, u16 vlan, u8 qos);
1191+ int queue, u16 vlan,
1192+ u8 qos, __be16 proto);
11911193 int (*ndo_set_vf_rate)(struct net_device *dev,
11921194 int vf, int min_tx_rate,
11931195 int max_tx_rate);
include/uapi/linux/if_link.h+18−1
@@ -619,7 +619,7 @@ enum { · 618 unmodified lines
619619 enum {
620620 IFLA_VF_UNSPEC,
621621 IFLA_VF_MAC, /* Hardware queue specific attributes */
622− IFLA_VF_VLAN,
622+ IFLA_VF_VLAN, /* VLAN ID and QoS */
623623 IFLA_VF_TX_RATE, /* Max TX Bandwidth Allocation */
624624 IFLA_VF_SPOOFCHK, /* Spoof Checking on/off switch */
625625 IFLA_VF_LINK_STATE, /* link state enable/disable/auto switch */
@@ -631,6 +631,7 @@ enum { · 5 unmodified lines
631631 IFLA_VF_TRUST, /* Trust VF */
632632 IFLA_VF_IB_NODE_GUID, /* VF Infiniband node GUID */
633633 IFLA_VF_IB_PORT_GUID, /* VF Infiniband port GUID */
634+ IFLA_VF_VLAN_LIST, /* nested list of vlans, option for QinQ */
634635 __IFLA_VF_MAX,
635636 };
636637
@@ -647,6 +648,22 @@ struct ifla_vf_vlan { · 10 unmodified lines
647648 __u32 qos;
648649 };
649650
651+enum {
652+ IFLA_VF_VLAN_INFO_UNSPEC,
653+ IFLA_VF_VLAN_INFO, /* VLAN ID, QoS and VLAN protocol */
654+ __IFLA_VF_VLAN_INFO_MAX,
655+};
656+
657+#define IFLA_VF_VLAN_INFO_MAX (__IFLA_VF_VLAN_INFO_MAX - 1)
658+#define MAX_VLAN_LIST_LEN 1
659+
660+struct ifla_vf_vlan_info {
661+ __u32 vf;
662+ __u32 vlan; /* 0 - 4095, 0 disables VLAN filter */
663+ __u32 qos;
664+ __be16 vlan_proto; /* VLAN protocol either 802.1Q or 802.1ad */
665+};
666+
650667 struct ifla_vf_tx_rate {
651668 __u32 vf;
652669 __u32 rate; /* Max TX bandwidth in Mbps, 0 disables throttling */
net/core/rtnetlink.c+65−15
@@ -843,7 +843,10 @@ static inline int rtnl_vfinfo_size(const struct net_device *dev, · 842 unmodified lines
843843 size += nla_total_size(num_vfs * sizeof(struct nlattr));
844844 size += num_vfs *
845845 (nla_total_size(sizeof(struct ifla_vf_mac)) +
846− nla_total_size(sizeof(struct ifla_vf_vlan)) +
846+ nla_total_size(MAX_VLAN_LIST_LEN *
847+ sizeof(struct nlattr)) +
848+ nla_total_size(MAX_VLAN_LIST_LEN *
849+ sizeof(struct ifla_vf_vlan_info)) +
847850 nla_total_size(sizeof(struct ifla_vf_spoofchk)) +
848851 nla_total_size(sizeof(struct ifla_vf_rate)) +
849852 nla_total_size(sizeof(struct ifla_vf_link_state)) +
@@ -1111,14 +1114,15 @@ static noinline_for_stack int rtnl_fill_vfinfo(struct sk_buff *skb, · 261 unmodified lines
11111114 struct nlattr *vfinfo)
11121115 {
11131116 struct ifla_vf_rss_query_en vf_rss_query_en;
1117+ struct nlattr *vf, *vfstats, *vfvlanlist;
11141118 struct ifla_vf_link_state vf_linkstate;
1119+ struct ifla_vf_vlan_info vf_vlan_info;
11151120 struct ifla_vf_spoofchk vf_spoofchk;
11161121 struct ifla_vf_tx_rate vf_tx_rate;
11171122 struct ifla_vf_stats vf_stats;
11181123 struct ifla_vf_trust vf_trust;
11191124 struct ifla_vf_vlan vf_vlan;
11201125 struct ifla_vf_rate vf_rate;
1121− struct nlattr *vf, *vfstats;
11221126 struct ifla_vf_mac vf_mac;
11231127 struct ifla_vf_info ivi;
11241128
@@ -1135,11 +1139,14 @@ static noinline_for_stack int rtnl_fill_vfinfo(struct sk_buff *skb, · 10 unmodified lines
11351139 * IFLA_VF_LINK_STATE_AUTO which equals zero
11361140 */
11371141 ivi.linkstate = 0;
1142+ /* VLAN Protocol by default is 802.1Q */
1143+ ivi.vlan_proto = htons(ETH_P_8021Q);
11381144 if (dev->netdev_ops->ndo_get_vf_config(dev, vfs_num, &ivi))
11391145 return 0;
11401146
11411147 vf_mac.vf =
11421148 vf_vlan.vf =
1149+ vf_vlan_info.vf =
11431150 vf_rate.vf =
11441151 vf_tx_rate.vf =
11451152 vf_spoofchk.vf =
@@ -1150,6 +1157,9 @@ static noinline_for_stack int rtnl_fill_vfinfo(struct sk_buff *skb, · 4 unmodified lines
11501157 memcpy(vf_mac.mac, ivi.mac, sizeof(ivi.mac));
11511158 vf_vlan.vlan = ivi.vlan;
11521159 vf_vlan.qos = ivi.qos;
1160+ vf_vlan_info.vlan = ivi.vlan;
1161+ vf_vlan_info.qos = ivi.qos;
1162+ vf_vlan_info.vlan_proto = ivi.vlan_proto;
11531163 vf_tx_rate.rate = ivi.max_tx_rate;
11541164 vf_rate.min_tx_rate = ivi.min_tx_rate;
11551165 vf_rate.max_tx_rate = ivi.max_tx_rate;
@@ -1158,10 +1168,8 @@ static noinline_for_stack int rtnl_fill_vfinfo(struct sk_buff *skb, · 2 unmodified lines
11581168 vf_rss_query_en.setting = ivi.rss_query_en;
11591169 vf_trust.setting = ivi.trusted;
11601170 vf = nla_nest_start(skb, IFLA_VF_INFO);
1161− if (!vf) {
1162− nla_nest_cancel(skb, vfinfo);
1163− return -EMSGSIZE;
1164− }
1171+ if (!vf)
1172+ goto nla_put_vfinfo_failure;
11651173 if (nla_put(skb, IFLA_VF_MAC, sizeof(vf_mac), &vf_mac) ||
11661174 nla_put(skb, IFLA_VF_VLAN, sizeof(vf_vlan), &vf_vlan) ||
11671175 nla_put(skb, IFLA_VF_RATE, sizeof(vf_rate),
@@ -1177,17 +1185,23 @@ static noinline_for_stack int rtnl_fill_vfinfo(struct sk_buff *skb, · 9 unmodified lines
11771185 &vf_rss_query_en) ||
11781186 nla_put(skb, IFLA_VF_TRUST,
11791187 sizeof(vf_trust), &vf_trust))
1180− return -EMSGSIZE;
1188+ goto nla_put_vf_failure;
1189+ vfvlanlist = nla_nest_start(skb, IFLA_VF_VLAN_LIST);
1190+ if (!vfvlanlist)
1191+ goto nla_put_vf_failure;
1192+ if (nla_put(skb, IFLA_VF_VLAN_INFO, sizeof(vf_vlan_info),
1193+ &vf_vlan_info)) {
1194+ nla_nest_cancel(skb, vfvlanlist);
1195+ goto nla_put_vf_failure;
1196+ }
1197+ nla_nest_end(skb, vfvlanlist);
11811198 memset(&vf_stats, 0, sizeof(vf_stats));
11821199 if (dev->netdev_ops->ndo_get_vf_stats)
11831200 dev->netdev_ops->ndo_get_vf_stats(dev, vfs_num,
11841201 &vf_stats);
11851202 vfstats = nla_nest_start(skb, IFLA_VF_STATS);
1186− if (!vfstats) {
1187− nla_nest_cancel(skb, vf);
1188− nla_nest_cancel(skb, vfinfo);
1189− return -EMSGSIZE;
1190− }
1203+ if (!vfstats)
1204+ goto nla_put_vf_failure;
11911205 if (nla_put_u64_64bit(skb, IFLA_VF_STATS_RX_PACKETS,
11921206 vf_stats.rx_packets, IFLA_VF_STATS_PAD) ||
11931207 nla_put_u64_64bit(skb, IFLA_VF_STATS_TX_PACKETS,
@@ -1199,11 +1213,19 @@ static noinline_for_stack int rtnl_fill_vfinfo(struct sk_buff *skb, · 5 unmodified lines
11991213 nla_put_u64_64bit(skb, IFLA_VF_STATS_BROADCAST,
12001214 vf_stats.broadcast, IFLA_VF_STATS_PAD) ||
12011215 nla_put_u64_64bit(skb, IFLA_VF_STATS_MULTICAST,
1202− vf_stats.multicast, IFLA_VF_STATS_PAD))
1203− return -EMSGSIZE;
1216+ vf_stats.multicast, IFLA_VF_STATS_PAD)) {
1217+ nla_nest_cancel(skb, vfstats);
1218+ goto nla_put_vf_failure;
1219+ }
12041220 nla_nest_end(skb, vfstats);
12051221 nla_nest_end(skb, vf);
12061222 return 0;
1223+
1224+nla_put_vf_failure:
1225+ nla_nest_cancel(skb, vf);
1226+nla_put_vfinfo_failure:
1227+ nla_nest_cancel(skb, vfinfo);
1228+ return -EMSGSIZE;
12071229 }
12081230
12091231 static int rtnl_fill_link_ifmap(struct sk_buff *skb, struct net_device *dev)
@@ -1448,6 +1470,7 @@ static const struct nla_policy ifla_info_policy[IFLA_INFO_MAX+1] = { · 238 unmodified lines
14481470 static const struct nla_policy ifla_vf_policy[IFLA_VF_MAX+1] = {
14491471 [IFLA_VF_MAC] = { .len = sizeof(struct ifla_vf_mac) },
14501472 [IFLA_VF_VLAN] = { .len = sizeof(struct ifla_vf_vlan) },
1473+ [IFLA_VF_VLAN_LIST] = { .type = NLA_NESTED },
14511474 [IFLA_VF_TX_RATE] = { .len = sizeof(struct ifla_vf_tx_rate) },
14521475 [IFLA_VF_SPOOFCHK] = { .len = sizeof(struct ifla_vf_spoofchk) },
14531476 [IFLA_VF_RATE] = { .len = sizeof(struct ifla_vf_rate) },
@@ -1704,7 +1727,34 @@ static int do_setvfinfo(struct net_device *dev, struct nlattr **tb) · 250 unmodified lines
17041727 err = -EOPNOTSUPP;
17051728 if (ops->ndo_set_vf_vlan)
17061729 err = ops->ndo_set_vf_vlan(dev, ivv->vf, ivv->vlan,
1707− ivv->qos);
1730+ ivv->qos,
1731+ htons(ETH_P_8021Q));
1732+ if (err < 0)
1733+ return err;
1734+ }
1735+
1736+ if (tb[IFLA_VF_VLAN_LIST]) {
1737+ struct ifla_vf_vlan_info *ivvl[MAX_VLAN_LIST_LEN];
1738+ struct nlattr *attr;
1739+ int rem, len = 0;
1740+
1741+ err = -EOPNOTSUPP;
1742+ if (!ops->ndo_set_vf_vlan)
1743+ return err;
1744+
1745+ nla_for_each_nested(attr, tb[IFLA_VF_VLAN_LIST], rem) {
1746+ if (nla_type(attr) != IFLA_VF_VLAN_INFO ||
1747+ nla_len(attr) < NLA_HDRLEN) {
1748+ return -EINVAL;
1749+ }
1750+ if (len >= MAX_VLAN_LIST_LEN)
1751+ return -EOPNOTSUPP;
1752+ ivvl[len] = nla_data(attr);
1753+
1754+ len++;
1755+ }
1756+ err = ops->ndo_set_vf_vlan(dev, ivvl[0]->vf, ivvl[0]->vlan,
1757+ ivvl[0]->qos, ivvl[0]->vlan_proto);
17081758 if (err < 0)
17091759 return err;
17101760 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t