Commit 54f07712 authored by Michal Swiatkowski's avatar Michal Swiatkowski Committed by Tony Nguyen

ice: implement netdevice ops for SF representor

Subfunction port representor needs the basic netdevice ops to work
correctly. Create them.
Reviewed-by: default avatarWojciech Drewek <wojciech.drewek@intel.com>
Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Signed-off-by: default avatarMichal Swiatkowski <michal.swiatkowski@linux.intel.com>
Tested-by: default avatarRafal Romanowski <rafal.romanowski@intel.com>
Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
parent 0f00a897
...@@ -59,12 +59,13 @@ static void ...@@ -59,12 +59,13 @@ static void
ice_repr_get_stats64(struct net_device *netdev, struct rtnl_link_stats64 *stats) ice_repr_get_stats64(struct net_device *netdev, struct rtnl_link_stats64 *stats)
{ {
struct ice_netdev_priv *np = netdev_priv(netdev); struct ice_netdev_priv *np = netdev_priv(netdev);
struct ice_repr *repr = np->repr;
struct ice_eth_stats *eth_stats; struct ice_eth_stats *eth_stats;
struct ice_vsi *vsi; struct ice_vsi *vsi;
if (ice_is_vf_disabled(np->repr->vf)) if (repr->ops.ready(repr))
return; return;
vsi = np->repr->src_vsi; vsi = repr->src_vsi;
ice_update_vsi_stats(vsi); ice_update_vsi_stats(vsi);
eth_stats = &vsi->eth_stats; eth_stats = &vsi->eth_stats;
...@@ -93,7 +94,7 @@ struct ice_repr *ice_netdev_to_repr(const struct net_device *netdev) ...@@ -93,7 +94,7 @@ struct ice_repr *ice_netdev_to_repr(const struct net_device *netdev)
} }
/** /**
* ice_repr_open - Enable port representor's network interface * ice_repr_vf_open - Enable port representor's network interface
* @netdev: network interface device structure * @netdev: network interface device structure
* *
* The open entry point is called when a port representor's network * The open entry point is called when a port representor's network
...@@ -102,7 +103,7 @@ struct ice_repr *ice_netdev_to_repr(const struct net_device *netdev) ...@@ -102,7 +103,7 @@ struct ice_repr *ice_netdev_to_repr(const struct net_device *netdev)
* *
* Returns 0 on success * Returns 0 on success
*/ */
static int ice_repr_open(struct net_device *netdev) static int ice_repr_vf_open(struct net_device *netdev)
{ {
struct ice_repr *repr = ice_netdev_to_repr(netdev); struct ice_repr *repr = ice_netdev_to_repr(netdev);
struct ice_vf *vf; struct ice_vf *vf;
...@@ -118,8 +119,16 @@ static int ice_repr_open(struct net_device *netdev) ...@@ -118,8 +119,16 @@ static int ice_repr_open(struct net_device *netdev)
return 0; return 0;
} }
static int ice_repr_sf_open(struct net_device *netdev)
{
netif_carrier_on(netdev);
netif_tx_start_all_queues(netdev);
return 0;
}
/** /**
* ice_repr_stop - Disable port representor's network interface * ice_repr_vf_stop - Disable port representor's network interface
* @netdev: network interface device structure * @netdev: network interface device structure
* *
* The stop entry point is called when a port representor's network * The stop entry point is called when a port representor's network
...@@ -128,7 +137,7 @@ static int ice_repr_open(struct net_device *netdev) ...@@ -128,7 +137,7 @@ static int ice_repr_open(struct net_device *netdev)
* *
* Returns 0 on success * Returns 0 on success
*/ */
static int ice_repr_stop(struct net_device *netdev) static int ice_repr_vf_stop(struct net_device *netdev)
{ {
struct ice_repr *repr = ice_netdev_to_repr(netdev); struct ice_repr *repr = ice_netdev_to_repr(netdev);
struct ice_vf *vf; struct ice_vf *vf;
...@@ -144,6 +153,14 @@ static int ice_repr_stop(struct net_device *netdev) ...@@ -144,6 +153,14 @@ static int ice_repr_stop(struct net_device *netdev)
return 0; return 0;
} }
static int ice_repr_sf_stop(struct net_device *netdev)
{
netif_carrier_off(netdev);
netif_tx_stop_all_queues(netdev);
return 0;
}
/** /**
* ice_repr_sp_stats64 - get slow path stats for port representor * ice_repr_sp_stats64 - get slow path stats for port representor
* @dev: network interface device structure * @dev: network interface device structure
...@@ -245,10 +262,20 @@ ice_repr_setup_tc(struct net_device *netdev, enum tc_setup_type type, ...@@ -245,10 +262,20 @@ ice_repr_setup_tc(struct net_device *netdev, enum tc_setup_type type,
} }
} }
static const struct net_device_ops ice_repr_netdev_ops = { static const struct net_device_ops ice_repr_vf_netdev_ops = {
.ndo_get_stats64 = ice_repr_get_stats64,
.ndo_open = ice_repr_vf_open,
.ndo_stop = ice_repr_vf_stop,
.ndo_start_xmit = ice_eswitch_port_start_xmit,
.ndo_setup_tc = ice_repr_setup_tc,
.ndo_has_offload_stats = ice_repr_ndo_has_offload_stats,
.ndo_get_offload_stats = ice_repr_ndo_get_offload_stats,
};
static const struct net_device_ops ice_repr_sf_netdev_ops = {
.ndo_get_stats64 = ice_repr_get_stats64, .ndo_get_stats64 = ice_repr_get_stats64,
.ndo_open = ice_repr_open, .ndo_open = ice_repr_sf_open,
.ndo_stop = ice_repr_stop, .ndo_stop = ice_repr_sf_stop,
.ndo_start_xmit = ice_eswitch_port_start_xmit, .ndo_start_xmit = ice_eswitch_port_start_xmit,
.ndo_setup_tc = ice_repr_setup_tc, .ndo_setup_tc = ice_repr_setup_tc,
.ndo_has_offload_stats = ice_repr_ndo_has_offload_stats, .ndo_has_offload_stats = ice_repr_ndo_has_offload_stats,
...@@ -261,18 +288,20 @@ static const struct net_device_ops ice_repr_netdev_ops = { ...@@ -261,18 +288,20 @@ static const struct net_device_ops ice_repr_netdev_ops = {
*/ */
bool ice_is_port_repr_netdev(const struct net_device *netdev) bool ice_is_port_repr_netdev(const struct net_device *netdev)
{ {
return netdev && (netdev->netdev_ops == &ice_repr_netdev_ops); return netdev && (netdev->netdev_ops == &ice_repr_vf_netdev_ops ||
netdev->netdev_ops == &ice_repr_sf_netdev_ops);
} }
/** /**
* ice_repr_reg_netdev - register port representor netdev * ice_repr_reg_netdev - register port representor netdev
* @netdev: pointer to port representor netdev * @netdev: pointer to port representor netdev
* @ops: new ops for netdev
*/ */
static int static int
ice_repr_reg_netdev(struct net_device *netdev) ice_repr_reg_netdev(struct net_device *netdev, const struct net_device_ops *ops)
{ {
eth_hw_addr_random(netdev); eth_hw_addr_random(netdev);
netdev->netdev_ops = &ice_repr_netdev_ops; netdev->netdev_ops = ops;
ice_set_ethtool_repr_ops(netdev); ice_set_ethtool_repr_ops(netdev);
netdev->hw_features |= NETIF_F_HW_TC; netdev->hw_features |= NETIF_F_HW_TC;
...@@ -386,7 +415,7 @@ static int ice_repr_add_vf(struct ice_repr *repr) ...@@ -386,7 +415,7 @@ static int ice_repr_add_vf(struct ice_repr *repr)
return err; return err;
SET_NETDEV_DEVLINK_PORT(repr->netdev, &vf->devlink_port); SET_NETDEV_DEVLINK_PORT(repr->netdev, &vf->devlink_port);
err = ice_repr_reg_netdev(repr->netdev); err = ice_repr_reg_netdev(repr->netdev, &ice_repr_vf_netdev_ops);
if (err) if (err)
goto err_netdev; goto err_netdev;
...@@ -447,7 +476,7 @@ static int ice_repr_add_sf(struct ice_repr *repr) ...@@ -447,7 +476,7 @@ static int ice_repr_add_sf(struct ice_repr *repr)
return err; return err;
SET_NETDEV_DEVLINK_PORT(repr->netdev, &sf->devlink_port); SET_NETDEV_DEVLINK_PORT(repr->netdev, &sf->devlink_port);
err = ice_repr_reg_netdev(repr->netdev); err = ice_repr_reg_netdev(repr->netdev, &ice_repr_sf_netdev_ops);
if (err) if (err)
goto err_netdev; goto err_netdev;
......
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