Skip to content

Commit 79aab09

Browse files
Moshe Shemeshdavem330
authored andcommitted
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 Signed-off-by: Moshe Shemesh <moshe@mellanox.com> Signed-off-by: Tariq Toukan <tariqt@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 0815fe3 commit 79aab09

File tree

23 files changed

+161
-42
lines changed

23 files changed

+161
-42
lines changed

drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,8 @@ int __bnx2x_setup_tc(struct net_device *dev, u32 handle, __be16 proto,
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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2521,7 +2521,8 @@ void bnx2x_pf_set_vfs_vlan(struct bnx2x *bp)
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,
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)
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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,8 @@ int bnxt_set_vf_mac(struct net_device *dev, int vf_id, u8 *mac)
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)
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1895,7 +1895,8 @@ static int be_clear_vf_tvt(struct be_adapter *adapter, int vf)
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)
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ int fm10k_iov_configure(struct pci_dev *pdev, int num_vfs);
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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ int fm10k_ndo_set_vf_mac(struct net_device *netdev, int vf_idx, u8 *mac)
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,
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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2747,11 +2747,12 @@ int i40e_ndo_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac)
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,
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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ void i40e_vc_notify_vf_reset(struct i40e_vf *vf);
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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ static int igb_set_vf_mac(struct igb_adapter *, int, unsigned char *);
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)
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
}

0 commit comments

Comments
 (0)