Commit 48ccc43e authored by Brett Creeley's avatar Brett Creeley Committed by Tony Nguyen

iavf: Add support VIRTCHNL_VF_OFFLOAD_VLAN_V2 during netdev config

Based on VIRTCHNL_VF_OFFLOAD_VLAN_V2, the VF can now support more VLAN
capabilities (i.e. 802.1AD offloads and filtering). In order to
communicate these capabilities to the netdev layer, the VF needs to
parse its VLAN capabilities based on whether it was able to negotiation
VIRTCHNL_VF_OFFLOAD_VLAN or VIRTCHNL_VF_OFFLOAD_VLAN_V2 or neither of
these.

In order to support this, add the following functionality:

iavf_get_netdev_vlan_hw_features() - This is used to determine the VLAN
features that the underlying hardware supports and that can be toggled
off/on based on the negotiated capabiltiies. For example, if
VIRTCHNL_VF_OFFLOAD_VLAN_V2 was negotiated, then any capability marked
with VIRTCHNL_VLAN_TOGGLE can be toggled on/off by the VF. If
VIRTCHNL_VF_OFFLOAD_VLAN was negotiated, then only VLAN insertion and/or
stripping can be toggled on/off.

iavf_get_netdev_vlan_features() - This is used to determine the VLAN
features that the underlying hardware supports and that should be
enabled by default. For example, if VIRTHCNL_VF_OFFLOAD_VLAN_V2 was
negotiated, then any supported capability that has its ethertype_init
filed set should be enabled by default. If VIRTCHNL_VF_OFFLOAD_VLAN was
negotiated, then filtering, stripping, and insertion should be enabled
by default.

Also, refactor iavf_fix_features() to take into account the new
capabilities. To do this, query all the supported features (enabled by
default and toggleable) and make sure the requested change is supported.
If VIRTCHNL_VF_OFFLOAD_VLAN_V2 is successfully negotiated, there is no
need to check VIRTCHNL_VLAN_TOGGLE here because the driver already told
the netdev layer which features can be toggled via netdev->hw_features
during iavf_process_config(), so only those features will be requested
to change.
Signed-off-by: default avatarBrett Creeley <brett.creeley@intel.com>
Tested-by: default avatarKonrad Jankowski <konrad0.jankowski@intel.com>
Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
parent 209f2f9c
...@@ -55,7 +55,8 @@ enum iavf_vsi_state_t { ...@@ -55,7 +55,8 @@ enum iavf_vsi_state_t {
struct iavf_vsi { struct iavf_vsi {
struct iavf_adapter *back; struct iavf_adapter *back;
struct net_device *netdev; struct net_device *netdev;
unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)]; unsigned long active_cvlans[BITS_TO_LONGS(VLAN_N_VID)];
unsigned long active_svlans[BITS_TO_LONGS(VLAN_N_VID)];
u16 seid; u16 seid;
u16 id; u16 id;
DECLARE_BITMAP(state, __IAVF_VSI_STATE_SIZE__); DECLARE_BITMAP(state, __IAVF_VSI_STATE_SIZE__);
...@@ -146,9 +147,15 @@ struct iavf_mac_filter { ...@@ -146,9 +147,15 @@ struct iavf_mac_filter {
}; };
}; };
#define IAVF_VLAN(vid, tpid) ((struct iavf_vlan){ vid, tpid })
struct iavf_vlan {
u16 vid;
u16 tpid;
};
struct iavf_vlan_filter { struct iavf_vlan_filter {
struct list_head list; struct list_head list;
u16 vlan; struct iavf_vlan vlan;
bool remove; /* filter needs to be removed */ bool remove; /* filter needs to be removed */
bool add; /* filter needs to be added */ bool add; /* filter needs to be added */
}; };
...@@ -354,6 +361,12 @@ struct iavf_adapter { ...@@ -354,6 +361,12 @@ struct iavf_adapter {
VIRTCHNL_VF_OFFLOAD_VLAN) VIRTCHNL_VF_OFFLOAD_VLAN)
#define VLAN_V2_ALLOWED(_a) ((_a)->vf_res->vf_cap_flags & \ #define VLAN_V2_ALLOWED(_a) ((_a)->vf_res->vf_cap_flags & \
VIRTCHNL_VF_OFFLOAD_VLAN_V2) VIRTCHNL_VF_OFFLOAD_VLAN_V2)
#define VLAN_V2_FILTERING_ALLOWED(_a) \
(VLAN_V2_ALLOWED((_a)) && \
((_a)->vlan_v2_caps.filtering.filtering_support.outer || \
(_a)->vlan_v2_caps.filtering.filtering_support.inner))
#define VLAN_FILTERING_ALLOWED(_a) \
(VLAN_ALLOWED((_a)) || VLAN_V2_FILTERING_ALLOWED((_a)))
#define ADV_LINK_SUPPORT(_a) ((_a)->vf_res->vf_cap_flags & \ #define ADV_LINK_SUPPORT(_a) ((_a)->vf_res->vf_cap_flags & \
VIRTCHNL_VF_CAP_ADV_LINK_SPEED) VIRTCHNL_VF_CAP_ADV_LINK_SPEED)
#define FDIR_FLTR_SUPPORT(_a) ((_a)->vf_res->vf_cap_flags & \ #define FDIR_FLTR_SUPPORT(_a) ((_a)->vf_res->vf_cap_flags & \
......
...@@ -646,14 +646,17 @@ static void iavf_configure_rx(struct iavf_adapter *adapter) ...@@ -646,14 +646,17 @@ static void iavf_configure_rx(struct iavf_adapter *adapter)
* mac_vlan_list_lock. * mac_vlan_list_lock.
**/ **/
static struct static struct
iavf_vlan_filter *iavf_find_vlan(struct iavf_adapter *adapter, u16 vlan) iavf_vlan_filter *iavf_find_vlan(struct iavf_adapter *adapter,
struct iavf_vlan vlan)
{ {
struct iavf_vlan_filter *f; struct iavf_vlan_filter *f;
list_for_each_entry(f, &adapter->vlan_filter_list, list) { list_for_each_entry(f, &adapter->vlan_filter_list, list) {
if (vlan == f->vlan) if (f->vlan.vid == vlan.vid &&
f->vlan.tpid == vlan.tpid)
return f; return f;
} }
return NULL; return NULL;
} }
...@@ -665,7 +668,8 @@ iavf_vlan_filter *iavf_find_vlan(struct iavf_adapter *adapter, u16 vlan) ...@@ -665,7 +668,8 @@ iavf_vlan_filter *iavf_find_vlan(struct iavf_adapter *adapter, u16 vlan)
* Returns ptr to the filter object or NULL when no memory available. * Returns ptr to the filter object or NULL when no memory available.
**/ **/
static struct static struct
iavf_vlan_filter *iavf_add_vlan(struct iavf_adapter *adapter, u16 vlan) iavf_vlan_filter *iavf_add_vlan(struct iavf_adapter *adapter,
struct iavf_vlan vlan)
{ {
struct iavf_vlan_filter *f = NULL; struct iavf_vlan_filter *f = NULL;
...@@ -694,7 +698,7 @@ iavf_vlan_filter *iavf_add_vlan(struct iavf_adapter *adapter, u16 vlan) ...@@ -694,7 +698,7 @@ iavf_vlan_filter *iavf_add_vlan(struct iavf_adapter *adapter, u16 vlan)
* @adapter: board private structure * @adapter: board private structure
* @vlan: VLAN tag * @vlan: VLAN tag
**/ **/
static void iavf_del_vlan(struct iavf_adapter *adapter, u16 vlan) static void iavf_del_vlan(struct iavf_adapter *adapter, struct iavf_vlan vlan)
{ {
struct iavf_vlan_filter *f; struct iavf_vlan_filter *f;
...@@ -720,8 +724,11 @@ static void iavf_restore_filters(struct iavf_adapter *adapter) ...@@ -720,8 +724,11 @@ static void iavf_restore_filters(struct iavf_adapter *adapter)
u16 vid; u16 vid;
/* re-add all VLAN filters */ /* re-add all VLAN filters */
for_each_set_bit(vid, adapter->vsi.active_vlans, VLAN_N_VID) for_each_set_bit(vid, adapter->vsi.active_cvlans, VLAN_N_VID)
iavf_add_vlan(adapter, vid); iavf_add_vlan(adapter, IAVF_VLAN(vid, ETH_P_8021Q));
for_each_set_bit(vid, adapter->vsi.active_svlans, VLAN_N_VID)
iavf_add_vlan(adapter, IAVF_VLAN(vid, ETH_P_8021AD));
} }
/** /**
...@@ -735,13 +742,17 @@ static int iavf_vlan_rx_add_vid(struct net_device *netdev, ...@@ -735,13 +742,17 @@ static int iavf_vlan_rx_add_vid(struct net_device *netdev,
{ {
struct iavf_adapter *adapter = netdev_priv(netdev); struct iavf_adapter *adapter = netdev_priv(netdev);
if (!VLAN_ALLOWED(adapter)) if (!VLAN_FILTERING_ALLOWED(adapter))
return -EIO; return -EIO;
if (iavf_add_vlan(adapter, vid) == NULL) if (!iavf_add_vlan(adapter, IAVF_VLAN(vid, be16_to_cpu(proto))))
return -ENOMEM; return -ENOMEM;
set_bit(vid, adapter->vsi.active_vlans); if (proto == cpu_to_be16(ETH_P_8021Q))
set_bit(vid, adapter->vsi.active_cvlans);
else
set_bit(vid, adapter->vsi.active_svlans);
return 0; return 0;
} }
...@@ -756,8 +767,11 @@ static int iavf_vlan_rx_kill_vid(struct net_device *netdev, ...@@ -756,8 +767,11 @@ static int iavf_vlan_rx_kill_vid(struct net_device *netdev,
{ {
struct iavf_adapter *adapter = netdev_priv(netdev); struct iavf_adapter *adapter = netdev_priv(netdev);
iavf_del_vlan(adapter, vid); iavf_del_vlan(adapter, IAVF_VLAN(vid, be16_to_cpu(proto)));
clear_bit(vid, adapter->vsi.active_vlans); if (proto == cpu_to_be16(ETH_P_8021Q))
clear_bit(vid, adapter->vsi.active_cvlans);
else
clear_bit(vid, adapter->vsi.active_svlans);
return 0; return 0;
} }
...@@ -3680,6 +3694,228 @@ static netdev_features_t iavf_features_check(struct sk_buff *skb, ...@@ -3680,6 +3694,228 @@ static netdev_features_t iavf_features_check(struct sk_buff *skb,
return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
} }
/**
* iavf_get_netdev_vlan_hw_features - get NETDEV VLAN features that can toggle on/off
* @adapter: board private structure
*
* Depending on whether VIRTHCNL_VF_OFFLOAD_VLAN or VIRTCHNL_VF_OFFLOAD_VLAN_V2
* were negotiated determine the VLAN features that can be toggled on and off.
**/
static netdev_features_t
iavf_get_netdev_vlan_hw_features(struct iavf_adapter *adapter)
{
netdev_features_t hw_features = 0;
if (!adapter->vf_res || !adapter->vf_res->vf_cap_flags)
return hw_features;
/* Enable VLAN features if supported */
if (VLAN_ALLOWED(adapter)) {
hw_features |= (NETIF_F_HW_VLAN_CTAG_TX |
NETIF_F_HW_VLAN_CTAG_RX);
} else if (VLAN_V2_ALLOWED(adapter)) {
struct virtchnl_vlan_caps *vlan_v2_caps =
&adapter->vlan_v2_caps;
struct virtchnl_vlan_supported_caps *stripping_support =
&vlan_v2_caps->offloads.stripping_support;
struct virtchnl_vlan_supported_caps *insertion_support =
&vlan_v2_caps->offloads.insertion_support;
if (stripping_support->outer != VIRTCHNL_VLAN_UNSUPPORTED &&
stripping_support->outer & VIRTCHNL_VLAN_TOGGLE) {
if (stripping_support->outer &
VIRTCHNL_VLAN_ETHERTYPE_8100)
hw_features |= NETIF_F_HW_VLAN_CTAG_RX;
if (stripping_support->outer &
VIRTCHNL_VLAN_ETHERTYPE_88A8)
hw_features |= NETIF_F_HW_VLAN_STAG_RX;
} else if (stripping_support->inner !=
VIRTCHNL_VLAN_UNSUPPORTED &&
stripping_support->inner & VIRTCHNL_VLAN_TOGGLE) {
if (stripping_support->inner &
VIRTCHNL_VLAN_ETHERTYPE_8100)
hw_features |= NETIF_F_HW_VLAN_CTAG_RX;
}
if (insertion_support->outer != VIRTCHNL_VLAN_UNSUPPORTED &&
insertion_support->outer & VIRTCHNL_VLAN_TOGGLE) {
if (insertion_support->outer &
VIRTCHNL_VLAN_ETHERTYPE_8100)
hw_features |= NETIF_F_HW_VLAN_CTAG_TX;
if (insertion_support->outer &
VIRTCHNL_VLAN_ETHERTYPE_88A8)
hw_features |= NETIF_F_HW_VLAN_STAG_TX;
} else if (insertion_support->inner &&
insertion_support->inner & VIRTCHNL_VLAN_TOGGLE) {
if (insertion_support->inner &
VIRTCHNL_VLAN_ETHERTYPE_8100)
hw_features |= NETIF_F_HW_VLAN_CTAG_TX;
}
}
return hw_features;
}
/**
* iavf_get_netdev_vlan_features - get the enabled NETDEV VLAN fetures
* @adapter: board private structure
*
* Depending on whether VIRTHCNL_VF_OFFLOAD_VLAN or VIRTCHNL_VF_OFFLOAD_VLAN_V2
* were negotiated determine the VLAN features that are enabled by default.
**/
static netdev_features_t
iavf_get_netdev_vlan_features(struct iavf_adapter *adapter)
{
netdev_features_t features = 0;
if (!adapter->vf_res || !adapter->vf_res->vf_cap_flags)
return features;
if (VLAN_ALLOWED(adapter)) {
features |= NETIF_F_HW_VLAN_CTAG_FILTER |
NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_HW_VLAN_CTAG_TX;
} else if (VLAN_V2_ALLOWED(adapter)) {
struct virtchnl_vlan_caps *vlan_v2_caps =
&adapter->vlan_v2_caps;
struct virtchnl_vlan_supported_caps *filtering_support =
&vlan_v2_caps->filtering.filtering_support;
struct virtchnl_vlan_supported_caps *stripping_support =
&vlan_v2_caps->offloads.stripping_support;
struct virtchnl_vlan_supported_caps *insertion_support =
&vlan_v2_caps->offloads.insertion_support;
u32 ethertype_init;
/* give priority to outer stripping and don't support both outer
* and inner stripping
*/
ethertype_init = vlan_v2_caps->offloads.ethertype_init;
if (stripping_support->outer != VIRTCHNL_VLAN_UNSUPPORTED) {
if (stripping_support->outer &
VIRTCHNL_VLAN_ETHERTYPE_8100 &&
ethertype_init & VIRTCHNL_VLAN_ETHERTYPE_8100)
features |= NETIF_F_HW_VLAN_CTAG_RX;
else if (stripping_support->outer &
VIRTCHNL_VLAN_ETHERTYPE_88A8 &&
ethertype_init & VIRTCHNL_VLAN_ETHERTYPE_88A8)
features |= NETIF_F_HW_VLAN_STAG_RX;
} else if (stripping_support->inner !=
VIRTCHNL_VLAN_UNSUPPORTED) {
if (stripping_support->inner &
VIRTCHNL_VLAN_ETHERTYPE_8100 &&
ethertype_init & VIRTCHNL_VLAN_ETHERTYPE_8100)
features |= NETIF_F_HW_VLAN_CTAG_RX;
}
/* give priority to outer insertion and don't support both outer
* and inner insertion
*/
if (insertion_support->outer != VIRTCHNL_VLAN_UNSUPPORTED) {
if (insertion_support->outer &
VIRTCHNL_VLAN_ETHERTYPE_8100 &&
ethertype_init & VIRTCHNL_VLAN_ETHERTYPE_8100)
features |= NETIF_F_HW_VLAN_CTAG_TX;
else if (insertion_support->outer &
VIRTCHNL_VLAN_ETHERTYPE_88A8 &&
ethertype_init & VIRTCHNL_VLAN_ETHERTYPE_88A8)
features |= NETIF_F_HW_VLAN_STAG_TX;
} else if (insertion_support->inner !=
VIRTCHNL_VLAN_UNSUPPORTED) {
if (insertion_support->inner &
VIRTCHNL_VLAN_ETHERTYPE_8100 &&
ethertype_init & VIRTCHNL_VLAN_ETHERTYPE_8100)
features |= NETIF_F_HW_VLAN_CTAG_TX;
}
/* give priority to outer filtering and don't bother if both
* outer and inner filtering are enabled
*/
ethertype_init = vlan_v2_caps->filtering.ethertype_init;
if (filtering_support->outer != VIRTCHNL_VLAN_UNSUPPORTED) {
if (filtering_support->outer &
VIRTCHNL_VLAN_ETHERTYPE_8100 &&
ethertype_init & VIRTCHNL_VLAN_ETHERTYPE_8100)
features |= NETIF_F_HW_VLAN_CTAG_FILTER;
if (filtering_support->outer &
VIRTCHNL_VLAN_ETHERTYPE_88A8 &&
ethertype_init & VIRTCHNL_VLAN_ETHERTYPE_88A8)
features |= NETIF_F_HW_VLAN_STAG_FILTER;
} else if (filtering_support->inner !=
VIRTCHNL_VLAN_UNSUPPORTED) {
if (filtering_support->inner &
VIRTCHNL_VLAN_ETHERTYPE_8100 &&
ethertype_init & VIRTCHNL_VLAN_ETHERTYPE_8100)
features |= NETIF_F_HW_VLAN_CTAG_FILTER;
if (filtering_support->inner &
VIRTCHNL_VLAN_ETHERTYPE_88A8 &&
ethertype_init & VIRTCHNL_VLAN_ETHERTYPE_88A8)
features |= NETIF_F_HW_VLAN_STAG_FILTER;
}
}
return features;
}
#define IAVF_NETDEV_VLAN_FEATURE_ALLOWED(requested, allowed, feature_bit) \
(!(((requested) & (feature_bit)) && \
!((allowed) & (feature_bit))))
/**
* iavf_fix_netdev_vlan_features - fix NETDEV VLAN features based on support
* @adapter: board private structure
* @requested_features: stack requested NETDEV features
**/
static netdev_features_t
iavf_fix_netdev_vlan_features(struct iavf_adapter *adapter,
netdev_features_t requested_features)
{
netdev_features_t allowed_features;
allowed_features = iavf_get_netdev_vlan_hw_features(adapter) |
iavf_get_netdev_vlan_features(adapter);
if (!IAVF_NETDEV_VLAN_FEATURE_ALLOWED(requested_features,
allowed_features,
NETIF_F_HW_VLAN_CTAG_TX))
requested_features &= ~NETIF_F_HW_VLAN_CTAG_TX;
if (!IAVF_NETDEV_VLAN_FEATURE_ALLOWED(requested_features,
allowed_features,
NETIF_F_HW_VLAN_CTAG_RX))
requested_features &= ~NETIF_F_HW_VLAN_CTAG_RX;
if (!IAVF_NETDEV_VLAN_FEATURE_ALLOWED(requested_features,
allowed_features,
NETIF_F_HW_VLAN_STAG_TX))
requested_features &= ~NETIF_F_HW_VLAN_STAG_TX;
if (!IAVF_NETDEV_VLAN_FEATURE_ALLOWED(requested_features,
allowed_features,
NETIF_F_HW_VLAN_STAG_RX))
requested_features &= ~NETIF_F_HW_VLAN_STAG_RX;
if (!IAVF_NETDEV_VLAN_FEATURE_ALLOWED(requested_features,
allowed_features,
NETIF_F_HW_VLAN_CTAG_FILTER))
requested_features &= ~NETIF_F_HW_VLAN_CTAG_FILTER;
if (!IAVF_NETDEV_VLAN_FEATURE_ALLOWED(requested_features,
allowed_features,
NETIF_F_HW_VLAN_STAG_FILTER))
requested_features &= ~NETIF_F_HW_VLAN_STAG_FILTER;
if ((requested_features &
(NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_HW_VLAN_CTAG_TX)) &&
(requested_features &
(NETIF_F_HW_VLAN_STAG_RX | NETIF_F_HW_VLAN_STAG_TX)) &&
adapter->vlan_v2_caps.offloads.ethertype_match ==
VIRTCHNL_ETHERTYPE_STRIPPING_MATCHES_INSERTION) {
netdev_warn(adapter->netdev, "cannot support CTAG and STAG VLAN stripping and/or insertion simultaneously since CTAG and STAG offloads are mutually exclusive, clearing STAG offload settings\n");
requested_features &= ~(NETIF_F_HW_VLAN_STAG_RX |
NETIF_F_HW_VLAN_STAG_TX);
}
return requested_features;
}
/** /**
* iavf_fix_features - fix up the netdev feature bits * iavf_fix_features - fix up the netdev feature bits
* @netdev: our net device * @netdev: our net device
...@@ -3692,13 +3928,7 @@ static netdev_features_t iavf_fix_features(struct net_device *netdev, ...@@ -3692,13 +3928,7 @@ static netdev_features_t iavf_fix_features(struct net_device *netdev,
{ {
struct iavf_adapter *adapter = netdev_priv(netdev); struct iavf_adapter *adapter = netdev_priv(netdev);
if (adapter->vf_res && return iavf_fix_netdev_vlan_features(adapter, features);
!(adapter->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_VLAN))
features &= ~(NETIF_F_HW_VLAN_CTAG_TX |
NETIF_F_HW_VLAN_CTAG_RX |
NETIF_F_HW_VLAN_CTAG_FILTER);
return features;
} }
static const struct net_device_ops iavf_netdev_ops = { static const struct net_device_ops iavf_netdev_ops = {
...@@ -3750,6 +3980,7 @@ static int iavf_check_reset_complete(struct iavf_hw *hw) ...@@ -3750,6 +3980,7 @@ static int iavf_check_reset_complete(struct iavf_hw *hw)
int iavf_process_config(struct iavf_adapter *adapter) int iavf_process_config(struct iavf_adapter *adapter)
{ {
struct virtchnl_vf_resource *vfres = adapter->vf_res; struct virtchnl_vf_resource *vfres = adapter->vf_res;
netdev_features_t hw_vlan_features, vlan_features;
struct net_device *netdev = adapter->netdev; struct net_device *netdev = adapter->netdev;
netdev_features_t hw_enc_features; netdev_features_t hw_enc_features;
netdev_features_t hw_features; netdev_features_t hw_features;
...@@ -3797,19 +4028,19 @@ int iavf_process_config(struct iavf_adapter *adapter) ...@@ -3797,19 +4028,19 @@ int iavf_process_config(struct iavf_adapter *adapter)
*/ */
hw_features = hw_enc_features; hw_features = hw_enc_features;
/* Enable VLAN features if supported */ /* get HW VLAN features that can be toggled */
if (vfres->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_VLAN) hw_vlan_features = iavf_get_netdev_vlan_hw_features(adapter);
hw_features |= (NETIF_F_HW_VLAN_CTAG_TX |
NETIF_F_HW_VLAN_CTAG_RX);
/* Enable cloud filter if ADQ is supported */ /* Enable cloud filter if ADQ is supported */
if (vfres->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_ADQ) if (vfres->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_ADQ)
hw_features |= NETIF_F_HW_TC; hw_features |= NETIF_F_HW_TC;
if (vfres->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_USO) if (vfres->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_USO)
hw_features |= NETIF_F_GSO_UDP_L4; hw_features |= NETIF_F_GSO_UDP_L4;
netdev->hw_features |= hw_features; netdev->hw_features |= hw_features | hw_vlan_features;
vlan_features = iavf_get_netdev_vlan_features(adapter);
netdev->features |= hw_features; netdev->features |= hw_features | vlan_features;
if (vfres->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_VLAN) if (vfres->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_VLAN)
netdev->features |= NETIF_F_HW_VLAN_CTAG_FILTER; netdev->features |= NETIF_F_HW_VLAN_CTAG_FILTER;
......
...@@ -642,7 +642,6 @@ static void iavf_mac_add_reject(struct iavf_adapter *adapter) ...@@ -642,7 +642,6 @@ static void iavf_mac_add_reject(struct iavf_adapter *adapter)
**/ **/
void iavf_add_vlans(struct iavf_adapter *adapter) void iavf_add_vlans(struct iavf_adapter *adapter)
{ {
struct virtchnl_vlan_filter_list *vvfl;
int len, i = 0, count = 0; int len, i = 0, count = 0;
struct iavf_vlan_filter *f; struct iavf_vlan_filter *f;
bool more = false; bool more = false;
...@@ -660,22 +659,23 @@ void iavf_add_vlans(struct iavf_adapter *adapter) ...@@ -660,22 +659,23 @@ void iavf_add_vlans(struct iavf_adapter *adapter)
if (f->add) if (f->add)
count++; count++;
} }
if (!count || !VLAN_ALLOWED(adapter)) { if (!count || !VLAN_FILTERING_ALLOWED(adapter)) {
adapter->aq_required &= ~IAVF_FLAG_AQ_ADD_VLAN_FILTER; adapter->aq_required &= ~IAVF_FLAG_AQ_ADD_VLAN_FILTER;
spin_unlock_bh(&adapter->mac_vlan_list_lock); spin_unlock_bh(&adapter->mac_vlan_list_lock);
return; return;
} }
if (VLAN_ALLOWED(adapter)) {
struct virtchnl_vlan_filter_list *vvfl;
adapter->current_op = VIRTCHNL_OP_ADD_VLAN; adapter->current_op = VIRTCHNL_OP_ADD_VLAN;
len = sizeof(struct virtchnl_vlan_filter_list) + len = sizeof(*vvfl) + (count * sizeof(u16));
(count * sizeof(u16));
if (len > IAVF_MAX_AQ_BUF_SIZE) { if (len > IAVF_MAX_AQ_BUF_SIZE) {
dev_warn(&adapter->pdev->dev, "Too many add VLAN changes in one request\n"); dev_warn(&adapter->pdev->dev, "Too many add VLAN changes in one request\n");
count = (IAVF_MAX_AQ_BUF_SIZE - count = (IAVF_MAX_AQ_BUF_SIZE - sizeof(*vvfl)) /
sizeof(struct virtchnl_vlan_filter_list)) /
sizeof(u16); sizeof(u16);
len = sizeof(struct virtchnl_vlan_filter_list) + len = sizeof(*vvfl) + (count * sizeof(u16));
(count * sizeof(u16));
more = true; more = true;
} }
vvfl = kzalloc(len, GFP_ATOMIC); vvfl = kzalloc(len, GFP_ATOMIC);
...@@ -688,7 +688,7 @@ void iavf_add_vlans(struct iavf_adapter *adapter) ...@@ -688,7 +688,7 @@ void iavf_add_vlans(struct iavf_adapter *adapter)
vvfl->num_elements = count; vvfl->num_elements = count;
list_for_each_entry(f, &adapter->vlan_filter_list, list) { list_for_each_entry(f, &adapter->vlan_filter_list, list) {
if (f->add) { if (f->add) {
vvfl->vlan_id[i] = f->vlan; vvfl->vlan_id[i] = f->vlan.vid;
i++; i++;
f->add = false; f->add = false;
if (i == count) if (i == count)
...@@ -702,6 +702,62 @@ void iavf_add_vlans(struct iavf_adapter *adapter) ...@@ -702,6 +702,62 @@ void iavf_add_vlans(struct iavf_adapter *adapter)
iavf_send_pf_msg(adapter, VIRTCHNL_OP_ADD_VLAN, (u8 *)vvfl, len); iavf_send_pf_msg(adapter, VIRTCHNL_OP_ADD_VLAN, (u8 *)vvfl, len);
kfree(vvfl); kfree(vvfl);
} else {
struct virtchnl_vlan_filter_list_v2 *vvfl_v2;
adapter->current_op = VIRTCHNL_OP_ADD_VLAN_V2;
len = sizeof(*vvfl_v2) + ((count - 1) *
sizeof(struct virtchnl_vlan_filter));
if (len > IAVF_MAX_AQ_BUF_SIZE) {
dev_warn(&adapter->pdev->dev, "Too many add VLAN changes in one request\n");
count = (IAVF_MAX_AQ_BUF_SIZE - sizeof(*vvfl_v2)) /
sizeof(struct virtchnl_vlan_filter);
len = sizeof(*vvfl_v2) +
((count - 1) *
sizeof(struct virtchnl_vlan_filter));
more = true;
}
vvfl_v2 = kzalloc(len, GFP_ATOMIC);
if (!vvfl_v2) {
spin_unlock_bh(&adapter->mac_vlan_list_lock);
return;
}
vvfl_v2->vport_id = adapter->vsi_res->vsi_id;
vvfl_v2->num_elements = count;
list_for_each_entry(f, &adapter->vlan_filter_list, list) {
if (f->add) {
struct virtchnl_vlan_supported_caps *filtering_support =
&adapter->vlan_v2_caps.filtering.filtering_support;
struct virtchnl_vlan *vlan;
/* give priority over outer if it's enabled */
if (filtering_support->outer)
vlan = &vvfl_v2->filters[i].outer;
else
vlan = &vvfl_v2->filters[i].inner;
vlan->tci = f->vlan.vid;
vlan->tpid = f->vlan.tpid;
i++;
f->add = false;
if (i == count)
break;
}
}
if (!more)
adapter->aq_required &= ~IAVF_FLAG_AQ_ADD_VLAN_FILTER;
spin_unlock_bh(&adapter->mac_vlan_list_lock);
iavf_send_pf_msg(adapter, VIRTCHNL_OP_ADD_VLAN_V2,
(u8 *)vvfl_v2, len);
kfree(vvfl_v2);
}
} }
/** /**
...@@ -712,7 +768,6 @@ void iavf_add_vlans(struct iavf_adapter *adapter) ...@@ -712,7 +768,6 @@ void iavf_add_vlans(struct iavf_adapter *adapter)
**/ **/
void iavf_del_vlans(struct iavf_adapter *adapter) void iavf_del_vlans(struct iavf_adapter *adapter)
{ {
struct virtchnl_vlan_filter_list *vvfl;
struct iavf_vlan_filter *f, *ftmp; struct iavf_vlan_filter *f, *ftmp;
int len, i = 0, count = 0; int len, i = 0, count = 0;
bool more = false; bool more = false;
...@@ -733,29 +788,30 @@ void iavf_del_vlans(struct iavf_adapter *adapter) ...@@ -733,29 +788,30 @@ void iavf_del_vlans(struct iavf_adapter *adapter)
* filters marked for removal to enable bailing out before * filters marked for removal to enable bailing out before
* sending a virtchnl message * sending a virtchnl message
*/ */
if (f->remove && !VLAN_ALLOWED(adapter)) { if (f->remove && !VLAN_FILTERING_ALLOWED(adapter)) {
list_del(&f->list); list_del(&f->list);
kfree(f); kfree(f);
} else if (f->remove) { } else if (f->remove) {
count++; count++;
} }
} }
if (!count) { if (!count || !VLAN_FILTERING_ALLOWED(adapter)) {
adapter->aq_required &= ~IAVF_FLAG_AQ_DEL_VLAN_FILTER; adapter->aq_required &= ~IAVF_FLAG_AQ_DEL_VLAN_FILTER;
spin_unlock_bh(&adapter->mac_vlan_list_lock); spin_unlock_bh(&adapter->mac_vlan_list_lock);
return; return;
} }
if (VLAN_ALLOWED(adapter)) {
struct virtchnl_vlan_filter_list *vvfl;
adapter->current_op = VIRTCHNL_OP_DEL_VLAN; adapter->current_op = VIRTCHNL_OP_DEL_VLAN;
len = sizeof(struct virtchnl_vlan_filter_list) + len = sizeof(*vvfl) + (count * sizeof(u16));
(count * sizeof(u16));
if (len > IAVF_MAX_AQ_BUF_SIZE) { if (len > IAVF_MAX_AQ_BUF_SIZE) {
dev_warn(&adapter->pdev->dev, "Too many delete VLAN changes in one request\n"); dev_warn(&adapter->pdev->dev, "Too many delete VLAN changes in one request\n");
count = (IAVF_MAX_AQ_BUF_SIZE - count = (IAVF_MAX_AQ_BUF_SIZE - sizeof(*vvfl)) /
sizeof(struct virtchnl_vlan_filter_list)) /
sizeof(u16); sizeof(u16);
len = sizeof(struct virtchnl_vlan_filter_list) + len = sizeof(*vvfl) + (count * sizeof(u16));
(count * sizeof(u16));
more = true; more = true;
} }
vvfl = kzalloc(len, GFP_ATOMIC); vvfl = kzalloc(len, GFP_ATOMIC);
...@@ -768,7 +824,7 @@ void iavf_del_vlans(struct iavf_adapter *adapter) ...@@ -768,7 +824,7 @@ void iavf_del_vlans(struct iavf_adapter *adapter)
vvfl->num_elements = count; vvfl->num_elements = count;
list_for_each_entry_safe(f, ftmp, &adapter->vlan_filter_list, list) { list_for_each_entry_safe(f, ftmp, &adapter->vlan_filter_list, list) {
if (f->remove) { if (f->remove) {
vvfl->vlan_id[i] = f->vlan; vvfl->vlan_id[i] = f->vlan.vid;
i++; i++;
list_del(&f->list); list_del(&f->list);
kfree(f); kfree(f);
...@@ -776,6 +832,7 @@ void iavf_del_vlans(struct iavf_adapter *adapter) ...@@ -776,6 +832,7 @@ void iavf_del_vlans(struct iavf_adapter *adapter)
break; break;
} }
} }
if (!more) if (!more)
adapter->aq_required &= ~IAVF_FLAG_AQ_DEL_VLAN_FILTER; adapter->aq_required &= ~IAVF_FLAG_AQ_DEL_VLAN_FILTER;
...@@ -783,6 +840,64 @@ void iavf_del_vlans(struct iavf_adapter *adapter) ...@@ -783,6 +840,64 @@ void iavf_del_vlans(struct iavf_adapter *adapter)
iavf_send_pf_msg(adapter, VIRTCHNL_OP_DEL_VLAN, (u8 *)vvfl, len); iavf_send_pf_msg(adapter, VIRTCHNL_OP_DEL_VLAN, (u8 *)vvfl, len);
kfree(vvfl); kfree(vvfl);
} else {
struct virtchnl_vlan_filter_list_v2 *vvfl_v2;
adapter->current_op = VIRTCHNL_OP_DEL_VLAN_V2;
len = sizeof(*vvfl_v2) +
((count - 1) * sizeof(struct virtchnl_vlan_filter));
if (len > IAVF_MAX_AQ_BUF_SIZE) {
dev_warn(&adapter->pdev->dev, "Too many add VLAN changes in one request\n");
count = (IAVF_MAX_AQ_BUF_SIZE -
sizeof(*vvfl_v2)) /
sizeof(struct virtchnl_vlan_filter);
len = sizeof(*vvfl_v2) +
((count - 1) *
sizeof(struct virtchnl_vlan_filter));
more = true;
}
vvfl_v2 = kzalloc(len, GFP_ATOMIC);
if (!vvfl_v2) {
spin_unlock_bh(&adapter->mac_vlan_list_lock);
return;
}
vvfl_v2->vport_id = adapter->vsi_res->vsi_id;
vvfl_v2->num_elements = count;
list_for_each_entry_safe(f, ftmp, &adapter->vlan_filter_list, list) {
if (f->remove) {
struct virtchnl_vlan_supported_caps *filtering_support =
&adapter->vlan_v2_caps.filtering.filtering_support;
struct virtchnl_vlan *vlan;
/* give priority over outer if it's enabled */
if (filtering_support->outer)
vlan = &vvfl_v2->filters[i].outer;
else
vlan = &vvfl_v2->filters[i].inner;
vlan->tci = f->vlan.vid;
vlan->tpid = f->vlan.tpid;
list_del(&f->list);
kfree(f);
i++;
if (i == count)
break;
}
}
if (!more)
adapter->aq_required &= ~IAVF_FLAG_AQ_DEL_VLAN_FILTER;
spin_unlock_bh(&adapter->mac_vlan_list_lock);
iavf_send_pf_msg(adapter, VIRTCHNL_OP_DEL_VLAN_V2,
(u8 *)vvfl_v2, len);
kfree(vvfl_v2);
}
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment