Commit 9eb03bb1 authored by Yinjun Zhang's avatar Yinjun Zhang Committed by Jakub Kicinski

nfp: add ethtool flow steering callbacks

This is the first part to implement flow steering. The communication
between ethtool and driver is done. User can use following commands
to display and set flows:

ethtool -n <netdev>
ethtool -N <netdev> flow-type ...
Signed-off-by: default avatarYinjun Zhang <yinjun.zhang@corigine.com>
Signed-off-by: default avatarLouis Peens <louis.peens@corigine.com>
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Link: https://lore.kernel.org/r/20231117071114.10667-2-louis.peens@corigine.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 21612f52
......@@ -621,6 +621,9 @@ struct nfp_net_dp {
* @mbox_amsg.lock: Protect message list
* @mbox_amsg.list: List of message to process
* @mbox_amsg.work: Work to process message asynchronously
* @fs: Flow steering
* @fs.count: Flow count
* @fs.list: List of flows
* @app_priv: APP private data for this vNIC
*/
struct nfp_net {
......@@ -728,9 +731,39 @@ struct nfp_net {
struct work_struct work;
} mbox_amsg;
struct {
u16 count;
struct list_head list;
} fs;
void *app_priv;
};
struct nfp_fs_entry {
struct list_head node;
u32 flow_type;
u32 loc;
struct {
union {
struct {
__be32 sip4;
__be32 dip4;
};
struct {
__be32 sip6[4];
__be32 dip6[4];
};
};
union {
__be16 l3_proto;
u8 l4_proto;
};
__be16 sport;
__be16 dport;
} key, msk;
u64 action;
};
struct nfp_mbox_amsg_entry {
struct list_head list;
int (*cfg)(struct nfp_net *nn, struct nfp_mbox_amsg_entry *entry);
......@@ -987,6 +1020,9 @@ struct nfp_net_dp *nfp_net_clone_dp(struct nfp_net *nn);
int nfp_net_ring_reconfig(struct nfp_net *nn, struct nfp_net_dp *new,
struct netlink_ext_ack *extack);
int nfp_net_fs_add_hw(struct nfp_net *nn, struct nfp_fs_entry *entry);
int nfp_net_fs_del_hw(struct nfp_net *nn, struct nfp_fs_entry *entry);
#ifdef CONFIG_NFP_DEBUG
void nfp_net_debugfs_create(void);
void nfp_net_debugfs_destroy(void);
......
......@@ -1763,6 +1763,27 @@ nfp_net_vlan_rx_kill_vid(struct net_device *netdev, __be16 proto, u16 vid)
return nfp_net_mbox_reconfig_and_unlock(nn, cmd);
}
int nfp_net_fs_add_hw(struct nfp_net *nn, struct nfp_fs_entry *entry)
{
return -EOPNOTSUPP;
}
int nfp_net_fs_del_hw(struct nfp_net *nn, struct nfp_fs_entry *entry)
{
return -EOPNOTSUPP;
}
static void nfp_net_fs_clean(struct nfp_net *nn)
{
struct nfp_fs_entry *entry, *tmp;
list_for_each_entry_safe(entry, tmp, &nn->fs.list, node) {
nfp_net_fs_del_hw(nn, entry);
list_del(&entry->node);
kfree(entry);
}
}
static void nfp_net_stat64(struct net_device *netdev,
struct rtnl_link_stats64 *stats)
{
......@@ -2740,6 +2761,8 @@ int nfp_net_init(struct nfp_net *nn)
INIT_LIST_HEAD(&nn->mbox_amsg.list);
INIT_WORK(&nn->mbox_amsg.work, nfp_net_mbox_amsg_work);
INIT_LIST_HEAD(&nn->fs.list);
return register_netdev(nn->dp.netdev);
err_clean_mbox:
......@@ -2759,6 +2782,7 @@ void nfp_net_clean(struct nfp_net *nn)
unregister_netdev(nn->dp.netdev);
nfp_net_ipsec_clean(nn);
nfp_ccm_mbox_clean(nn);
nfp_net_fs_clean(nn);
flush_work(&nn->mbox_amsg.work);
nfp_net_reconfig_wait_posted(nn);
}
......@@ -269,6 +269,7 @@
#define NFP_NET_CFG_CTRL_IPSEC (0x1 << 1) /* IPsec offload */
#define NFP_NET_CFG_CTRL_MCAST_FILTER (0x1 << 2) /* Multicast Filter */
#define NFP_NET_CFG_CTRL_FREELIST_EN (0x1 << 6) /* Freelist enable flag bit */
#define NFP_NET_CFG_CTRL_FLOW_STEER (0x1 << 8) /* Flow steering */
#define NFP_NET_CFG_CAP_WORD1 0x00a4
......
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