diff options
author | Jakub Kicinski | 2017-06-27 09:50:22 +0200 |
---|---|---|
committer | David S. Miller | 2017-06-27 21:48:48 +0200 |
commit | 5d7c64a70fa15aef903469b05ca664f7cd17d769 (patch) | |
tree | 2e34392f775b6d12855c527918333368a3bd83f0 /drivers/net/ethernet/netronome/nfp/nfp_net_repr.c | |
parent | nfp: make the representor get stats app-independent (diff) | |
download | kernel-qcow2-linux-5d7c64a70fa15aef903469b05ca664f7cd17d769.tar.gz kernel-qcow2-linux-5d7c64a70fa15aef903469b05ca664f7cd17d769.tar.xz kernel-qcow2-linux-5d7c64a70fa15aef903469b05ca664f7cd17d769.zip |
nfp: move representors' struct net_device_ops to shared code
Apps shouldn't declare their own struct net_device_ops for
representors, this makes sharing code harder. Add necessary
nfp_app callbacks and move the definition of representors'
struct net_device_ops to common code.
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Simon Horman <simon.horman@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/netronome/nfp/nfp_net_repr.c')
-rw-r--r-- | drivers/net/ethernet/netronome/nfp/nfp_net_repr.c | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c b/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c index 6f1548c6840c..44416f679fdb 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c @@ -136,7 +136,7 @@ nfp_repr_pf_get_stats64(const struct nfp_app *app, u8 pf, stats->rx_dropped = readq(mem + NFP_NET_CFG_STATS_TX_DISCARDS); } -void +static void nfp_repr_get_stats64(struct net_device *netdev, struct rtnl_link_stats64 *stats) { struct nfp_repr *repr = netdev_priv(netdev); @@ -163,7 +163,7 @@ nfp_repr_get_stats64(struct net_device *netdev, struct rtnl_link_stats64 *stats) } } -bool +static bool nfp_repr_has_offload_stats(const struct net_device *dev, int attr_id) { switch (attr_id) { @@ -206,8 +206,9 @@ nfp_repr_get_host_stats64(const struct net_device *netdev, return 0; } -int nfp_repr_get_offload_stats(int attr_id, const struct net_device *dev, - void *stats) +static int +nfp_repr_get_offload_stats(int attr_id, const struct net_device *dev, + void *stats) { switch (attr_id) { case IFLA_OFFLOAD_XSTATS_CPU_HIT: @@ -217,7 +218,7 @@ int nfp_repr_get_offload_stats(int attr_id, const struct net_device *dev, return -EINVAL; } -netdev_tx_t nfp_repr_xmit(struct sk_buff *skb, struct net_device *netdev) +static netdev_tx_t nfp_repr_xmit(struct sk_buff *skb, struct net_device *netdev) { struct nfp_repr *repr = netdev_priv(netdev); unsigned int len = skb->len; @@ -234,6 +235,29 @@ netdev_tx_t nfp_repr_xmit(struct sk_buff *skb, struct net_device *netdev) return ret; } +static int nfp_repr_stop(struct net_device *netdev) +{ + struct nfp_repr *repr = netdev_priv(netdev); + + return nfp_app_repr_stop(repr->app, repr); +} + +static int nfp_repr_open(struct net_device *netdev) +{ + struct nfp_repr *repr = netdev_priv(netdev); + + return nfp_app_repr_open(repr->app, repr); +} + +static const struct net_device_ops nfp_repr_netdev_ops = { + .ndo_open = nfp_repr_open, + .ndo_stop = nfp_repr_stop, + .ndo_start_xmit = nfp_repr_xmit, + .ndo_get_stats64 = nfp_repr_get_stats64, + .ndo_has_offload_stats = nfp_repr_has_offload_stats, + .ndo_get_offload_stats = nfp_repr_get_offload_stats, +}; + static void nfp_repr_clean(struct nfp_repr *repr) { unregister_netdev(repr->netdev); @@ -258,8 +282,8 @@ static void nfp_repr_set_lockdep_class(struct net_device *dev) } int nfp_repr_init(struct nfp_app *app, struct net_device *netdev, - const struct net_device_ops *netdev_ops, u32 cmsg_port_id, - struct nfp_port *port, struct net_device *pf_netdev) + u32 cmsg_port_id, struct nfp_port *port, + struct net_device *pf_netdev) { struct nfp_repr *repr = netdev_priv(netdev); int err; @@ -273,7 +297,7 @@ int nfp_repr_init(struct nfp_app *app, struct net_device *netdev, repr->dst->u.port_info.port_id = cmsg_port_id; repr->dst->u.port_info.lower_dev = pf_netdev; - netdev->netdev_ops = netdev_ops; + netdev->netdev_ops = &nfp_repr_netdev_ops; err = register_netdev(netdev); if (err) |