Commit 4d364df2 authored by Michal Swiatkowski's avatar Michal Swiatkowski Committed by Tony Nguyen

ice: move VSI configuration outside repr setup

It is needed because subfunction port representor shouldn't configure
the source VSI during representor creation.

Move the code to separate function and call it only in case the VF port
representor is being created.
Signed-off-by: default avatarMichal Swiatkowski <michal.swiatkowski@linux.intel.com>
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Tested-by: default avatarSujai Buvaneswaran <sujai.buvaneswaran@intel.com>
Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
parent 8d2f518c
...@@ -117,17 +117,10 @@ static int ice_eswitch_setup_repr(struct ice_pf *pf, struct ice_repr *repr) ...@@ -117,17 +117,10 @@ static int ice_eswitch_setup_repr(struct ice_pf *pf, struct ice_repr *repr)
struct ice_vsi *vsi = repr->src_vsi; struct ice_vsi *vsi = repr->src_vsi;
struct metadata_dst *dst; struct metadata_dst *dst;
ice_remove_vsi_fltr(&pf->hw, vsi->idx);
repr->dst = metadata_dst_alloc(0, METADATA_HW_PORT_MUX, repr->dst = metadata_dst_alloc(0, METADATA_HW_PORT_MUX,
GFP_KERNEL); GFP_KERNEL);
if (!repr->dst) if (!repr->dst)
goto err_add_mac_fltr; return -ENOMEM;
if (ice_vsi_update_security(vsi, ice_vsi_ctx_clear_antispoof))
goto err_dst_free;
if (ice_vsi_add_vlan_zero(vsi))
goto err_update_security;
netif_keep_dst(uplink_vsi->netdev); netif_keep_dst(uplink_vsi->netdev);
...@@ -136,16 +129,48 @@ static int ice_eswitch_setup_repr(struct ice_pf *pf, struct ice_repr *repr) ...@@ -136,16 +129,48 @@ static int ice_eswitch_setup_repr(struct ice_pf *pf, struct ice_repr *repr)
dst->u.port_info.lower_dev = uplink_vsi->netdev; dst->u.port_info.lower_dev = uplink_vsi->netdev;
return 0; return 0;
}
err_update_security: /**
* ice_eswitch_cfg_vsi - configure VSI to work in slow-path
* @vsi: VSI structure of representee
* @mac: representee MAC
*
* Return: 0 on success, non-zero on error.
*/
int ice_eswitch_cfg_vsi(struct ice_vsi *vsi, const u8 *mac)
{
int err;
ice_remove_vsi_fltr(&vsi->back->hw, vsi->idx);
err = ice_vsi_update_security(vsi, ice_vsi_ctx_clear_antispoof);
if (err)
goto err_update_security;
err = ice_vsi_add_vlan_zero(vsi);
if (err)
goto err_vlan_zero;
return 0;
err_vlan_zero:
ice_vsi_update_security(vsi, ice_vsi_ctx_set_antispoof); ice_vsi_update_security(vsi, ice_vsi_ctx_set_antispoof);
err_dst_free: err_update_security:
metadata_dst_free(repr->dst); ice_fltr_add_mac_and_broadcast(vsi, mac, ICE_FWD_TO_VSI);
repr->dst = NULL;
err_add_mac_fltr:
ice_fltr_add_mac_and_broadcast(vsi, repr->parent_mac, ICE_FWD_TO_VSI);
return -ENODEV; return err;
}
/**
* ice_eswitch_decfg_vsi - unroll changes done to VSI for switchdev
* @vsi: VSI structure of representee
* @mac: representee MAC
*/
void ice_eswitch_decfg_vsi(struct ice_vsi *vsi, const u8 *mac)
{
ice_vsi_update_security(vsi, ice_vsi_ctx_set_antispoof);
ice_fltr_add_mac_and_broadcast(vsi, mac, ICE_FWD_TO_VSI);
} }
/** /**
......
...@@ -28,6 +28,9 @@ netdev_tx_t ...@@ -28,6 +28,9 @@ netdev_tx_t
ice_eswitch_port_start_xmit(struct sk_buff *skb, struct net_device *netdev); ice_eswitch_port_start_xmit(struct sk_buff *skb, struct net_device *netdev);
struct net_device *ice_eswitch_get_target(struct ice_rx_ring *rx_ring, struct net_device *ice_eswitch_get_target(struct ice_rx_ring *rx_ring,
union ice_32b_rx_flex_desc *rx_desc); union ice_32b_rx_flex_desc *rx_desc);
int ice_eswitch_cfg_vsi(struct ice_vsi *vsi, const u8 *mac);
void ice_eswitch_decfg_vsi(struct ice_vsi *vsi, const u8 *mac);
#else /* CONFIG_ICE_SWITCHDEV */ #else /* CONFIG_ICE_SWITCHDEV */
static inline void ice_eswitch_detach(struct ice_pf *pf, struct ice_vf *vf) { } static inline void ice_eswitch_detach(struct ice_pf *pf, struct ice_vf *vf) { }
...@@ -85,5 +88,12 @@ ice_eswitch_get_target(struct ice_rx_ring *rx_ring, ...@@ -85,5 +88,12 @@ ice_eswitch_get_target(struct ice_rx_ring *rx_ring,
{ {
return rx_ring->netdev; return rx_ring->netdev;
} }
static inline int ice_eswitch_cfg_vsi(struct ice_vsi *vsi, const u8 *mac)
{
return -EOPNOTSUPP;
}
static inline void ice_eswitch_decfg_vsi(struct ice_vsi *vsi, const u8 *mac) { }
#endif /* CONFIG_ICE_SWITCHDEV */ #endif /* CONFIG_ICE_SWITCHDEV */
#endif /* _ICE_ESWITCH_H_ */ #endif /* _ICE_ESWITCH_H_ */
...@@ -306,6 +306,7 @@ static void ice_repr_rem(struct ice_repr *repr) ...@@ -306,6 +306,7 @@ static void ice_repr_rem(struct ice_repr *repr)
void ice_repr_rem_vf(struct ice_repr *repr) void ice_repr_rem_vf(struct ice_repr *repr)
{ {
ice_repr_remove_node(&repr->vf->devlink_port); ice_repr_remove_node(&repr->vf->devlink_port);
ice_eswitch_decfg_vsi(repr->src_vsi, repr->parent_mac);
unregister_netdev(repr->netdev); unregister_netdev(repr->netdev);
ice_devlink_destroy_vf_port(repr->vf); ice_devlink_destroy_vf_port(repr->vf);
ice_virtchnl_set_dflt_ops(repr->vf); ice_virtchnl_set_dflt_ops(repr->vf);
...@@ -401,11 +402,17 @@ struct ice_repr *ice_repr_add_vf(struct ice_vf *vf) ...@@ -401,11 +402,17 @@ struct ice_repr *ice_repr_add_vf(struct ice_vf *vf)
if (err) if (err)
goto err_netdev; goto err_netdev;
err = ice_eswitch_cfg_vsi(repr->src_vsi, repr->parent_mac);
if (err)
goto err_cfg_vsi;
ice_virtchnl_set_repr_ops(vf); ice_virtchnl_set_repr_ops(vf);
ice_repr_set_tx_topology(vf->pf); ice_repr_set_tx_topology(vf->pf);
return repr; return repr;
err_cfg_vsi:
unregister_netdev(repr->netdev);
err_netdev: err_netdev:
ice_repr_rem(repr); ice_repr_rem(repr);
err_repr_add: err_repr_add:
......
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