tc cls_u32 hardware interface
Subsystems (9)
cover tc cls_u32 hardware interface
I was waiting for net-next to open to submit this but it seems like a good idea to get an RFC out there for folks to start looking over.
This extends the setup_tc framework so it can support more than just the mqprio offload and push other classifiers and qdiscs into the hardware. The series here targets the u32 classifier and ixgbe driver. I worked out the u32 classifier because it is protocol oblivious and aligns with multiple hardware devices I have access to. I did an initial implementation on ixgbe because (a) I have one in my box (b) its a stable driver and (c) it is relatively simple compared to the other devices I have here but still has enough flexibility to exercise the features of cls_u32.
I intentionally limited the scope of this series to the basic feature set. Specifically this uses a 'big hammer' feature bit to do the offload or not. If the bit is set you get offloaded rules if it is not then rules will not be offloaded. If we can agree on this patch series there are some more patches on my queue we can talk about to make the offload decision per rule using flags similar to how we do l2 mac updates. Additionally the error strategy can be improved to be hard aborting, log and continue, etc. I think these are nice to have improvements but shouldn't block this series. I am working on similar support for the other Intel devices now as well namely i40e and fm10k.
Also in the future work bin by adding get_parse_graph and set_parse_graph attributes as in my previous flow_api work we can build programmable devices and programmatically learn when rules can or can not be loaded into the hardware.
Note this series is on a slightly behind net-next stack I think it should apply to the latest but I haven't updated the series for awhile I'll do that soon I was sort of waiting for net-next to open to do this.
Any comments/feedback appreciated.
Thanks,
John
---
John Fastabend (7):
net: rework ndo tc op to consume additional qdisc handle parameter
net: rework setup_tc ndo op to consume general tc operand
net: sched: add cls_u32 offload hooks for netdevs
net: add tc offload feature flag
net: tc: helper functions to query action types
net: ixgbe: add minimal parser details for ixgbe
net: ixgbe: add support for tc_u32 offload
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 8 + drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h | 2 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 2 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 9 + drivers/net/ethernet/intel/fm10k/fm10k_netdev.c | 11 + drivers/net/ethernet/intel/i40e/i40e_main.c | 10 + drivers/net/ethernet/intel/ixgbe/ixgbe.h | 3 drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 6 - drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 198 ++++++++++++++++++++++ drivers/net/ethernet/intel/ixgbe/ixgbe_model.h | 110 ++++++++++++ drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 13 + drivers/net/ethernet/sfc/efx.h | 3 drivers/net/ethernet/sfc/tx.c | 10 + drivers/net/ethernet/ti/netcp_core.c | 14 +- include/linux/netdev_features.h | 3 include/linux/netdevice.h | 24 +++ include/net/pkt_cls.h | 33 ++++ include/net/tc_act/tc_gact.h | 14 ++ net/core/ethtool.c | 1 net/sched/cls_u32.c | 73 ++++++++ net/sched/sch_mqprio.c | 8 + 21 files changed, 529 insertions(+), 26 deletions(-) create mode 100644 drivers/net/ethernet/intel/ixgbe/ixgbe_model.h
RFC PATCH 1/7 net: rework ndo tc op to consume additional qdisc handle parameter
The ndo_setup_tc() op was added to support drivers offloading tx qdiscs however only support for mqprio was ever added. So we only ever added support for passing the number of traffic classes to the driver.
This patch generalizes the ndo_setup_tc op so that a handle can be provided to indicate if the offload is for ingress or egress or potentially even child qdiscs.
--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 7 +++++++ drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h | 1 + drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 2 +- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 5 ++++- drivers/net/ethernet/intel/fm10k/fm10k_netdev.c | 10 +++++++++- drivers/net/ethernet/intel/i40e/i40e_main.c | 9 ++++++++- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 11 ++++++++++- drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 12 ++++++++++-- drivers/net/ethernet/sfc/efx.h | 2 +- drivers/net/ethernet/sfc/tx.c | 5 ++++- drivers/net/ethernet/ti/netcp_core.c | 5 ++++- include/linux/netdevice.h | 2 +- net/sched/sch_mqprio.c | 5 +++-- 13 files changed, 63 insertions(+), 13 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +7 -0
@@ -4268,6 +4268,13 @@ int bnx2x_setup_tc(struct net_device *dev, u8 num_tc)return 0 ; } +int __bnx2x_setup_tc (struct net_device *dev,u32 handle,u8 num_tc) +{ +if (handle !=TC_H_ROOT ) +return -EINVAL ; +return bnx2x_setup_tc (dev, num_tc); +} +/* called with rtnl_lock */ int bnx2x_change_mac_addr (struct net_device *dev,void *p) {
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h +1 -0
@@ -486,6 +486,7 @@ netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev);/* setup_tc callback */ int bnx2x_setup_tc (struct net_device *dev,u8 num_tc); +int __bnx2x_setup_tc (struct net_device *dev,u32 handle,u8 num_tc);int bnx2x_get_vf_config (struct net_device *dev,int vf,struct ifla_vf_info *ivi);
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +1 -1
@@ -12994,7 +12994,7 @@ static const struct net_device_ops bnx2x_netdev_ops = {#ifdef CONFIG_NET_POLL_CONTROLLER .ndo_poll_controller = poll_bnx2x, #endif - .ndo_setup_tc = bnx2x_setup_tc, + .ndo_setup_tc = __bnx2x_setup_tc, #ifdef CONFIG_BNX2X_SRIOV .ndo_set_vf_mac = bnx2x_set_vf_mac, .ndo_set_vf_vlan = bnx2x_set_vf_vlan,
drivers/net/ethernet/broadcom/bnxt/bnxt.c +4 -1
@@ -5260,10 +5260,13 @@ static int bnxt_change_mtu(struct net_device *dev, int new_mtu)return 0 ; } -static int bnxt_setup_tc (struct net_device *dev,u8 tc) +static int bnxt_setup_tc (struct net_device *dev,u32 handle,u8 tc) {struct bnxt *bp =netdev_priv (dev); +if (handle !=TC_H_ROOT ) +return -EINVAL ; +if (tc > bp->max_tc) {netdev_err (dev,"too many traffic classes requested: %d Max supported is %d\n" , tc, bp->max_tc);
drivers/net/ethernet/intel/fm10k/fm10k_netdev.c +9 -1
@@ -1190,6 +1190,14 @@ int fm10k_setup_tc(struct net_device *dev, u8 tc)return 0 ; } +static int __fm10k_setup_tc (struct net_device *dev,u32 handle,u8 tc) +{ +if (handle !=TC_H_ROOT ) +return -EINVAL ; + +return fm10k_setup_tc (dev, tc); +} +static int fm10k_ioctl (struct net_device *netdev,struct ifreq *ifr,int cmd) {switch (cmd) {
@@ -1372,7 +1380,7 @@ static const struct net_device_ops fm10k_netdev_ops = { .ndo_vlan_rx_kill_vid = fm10k_vlan_rx_kill_vid, .ndo_set_rx_mode = fm10k_set_rx_mode, .ndo_get_stats64 = fm10k_get_stats64, - .ndo_setup_tc = fm10k_setup_tc, + .ndo_setup_tc = __fm10k_setup_tc, .ndo_set_vf_mac = fm10k_ndo_set_vf_mac, .ndo_set_vf_vlan = fm10k_ndo_set_vf_vlan, .ndo_set_vf_rate = fm10k_ndo_set_vf_bw,
drivers/net/ethernet/intel/i40e/i40e_main.c +8 -1
@@ -5298,6 +5298,13 @@ exit:return ret; } +static int __i40e_setup_tc (struct net_device *netdev,u32 handle,u8 tc) +{ +if (handle !=TC_H_ROOT ) +return -EINVAL ; +return i40e_setup_tc (netdev, tc); +} +/** * i40e_open - Called when a network interface is made active * @netdev: network interface device structure
@@ -8887,7 +8894,7 @@ static const struct net_device_ops i40e_netdev_ops = {#ifdef CONFIG_NET_POLL_CONTROLLER .ndo_poll_controller = i40e_netpoll, #endif - .ndo_setup_tc = i40e_setup_tc, + .ndo_setup_tc = __i40e_setup_tc, #ifdef I40E_FCOE .ndo_fcoe_enable = i40e_fcoe_enable, .ndo_fcoe_disable = i40e_fcoe_disable,
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +10 -1
@@ -8167,6 +8167,15 @@ int ixgbe_setup_tc(struct net_device *dev, u8 tc)return 0 ; } +int __ixgbe_setup_tc (struct net_device *dev,u32 handle,u8 tc) +{ +/* Only support egress tc setup for now */ +if (handle !=TC_H_ROOT ) +return -EINVAL ; + +return ixgbe_setup_tc (dev, tc); +} +#ifdef CONFIG_PCI_IOV void ixgbe_sriov_reinit (struct ixgbe_adapter *adapter) {
@@ -8625,7 +8634,7 @@ static const struct net_device_ops ixgbe_netdev_ops = { .ndo_get_vf_config = ixgbe_ndo_get_vf_config, .ndo_get_stats64 = ixgbe_get_stats64,#ifdef CONFIG_IXGBE_DCB - .ndo_setup_tc = ixgbe_setup_tc, + .ndo_setup_tc = __ixgbe_setup_tc,#endif #ifdef CONFIG_NET_POLL_CONTROLLER .ndo_poll_controller = ixgbe_netpoll,
drivers/net/ethernet/mellanox/mlx4/en_netdev.c +10 -2
@@ -69,6 +69,14 @@ int mlx4_en_setup_tc(struct net_device *dev, u8 up)return 0 ; } +static int __mlx4_en_setup_tc (struct net_device *dev,u32 handle,u8 up) +{ +if (handle !=TC_H_ROOT ) +return -EINVAL ; + +return mlx4_en_setup_tc (dev, up); +} +#ifdef CONFIG_RFS_ACCEL struct mlx4_en_filter {
@@ -2463,7 +2471,7 @@ static const struct net_device_ops mlx4_netdev_ops = {#endif .ndo_set_features = mlx4_en_set_features, .ndo_fix_features = mlx4_en_fix_features, - .ndo_setup_tc = mlx4_en_setup_tc, + .ndo_setup_tc = __mlx4_en_setup_tc,#ifdef CONFIG_RFS_ACCEL .ndo_rx_flow_steer = mlx4_en_filter_rfs,#endif
@@ -2501,7 +2509,7 @@ static const struct net_device_ops mlx4_netdev_ops_master = {#endif .ndo_set_features = mlx4_en_set_features, .ndo_fix_features = mlx4_en_fix_features, - .ndo_setup_tc = mlx4_en_setup_tc, + .ndo_setup_tc = __mlx4_en_setup_tc,#ifdef CONFIG_RFS_ACCEL .ndo_rx_flow_steer = mlx4_en_filter_rfs,#endif
drivers/net/ethernet/sfc/efx.h +1 -1
@@ -32,7 +32,7 @@ netdev_tx_t efx_hard_start_xmit(struct sk_buff *skb, struct net_device *net_dev);netdev_tx_t efx_enqueue_skb (struct efx_tx_queue *tx_queue,struct sk_buff *skb);void efx_xmit_done (struct efx_tx_queue *tx_queue,unsigned int index); -int efx_setup_tc (struct net_device *net_dev,u8 num_tc); +int efx_setup_tc (struct net_device *net_dev,u32 handle,u8 num_tc);unsigned int efx_tx_max_skb_descs (struct efx_nic *efx);extern unsigned int efx_piobuf_size;extern bool efx_separate_tx_channels;
drivers/net/ethernet/sfc/tx.c +4 -1
@@ -562,7 +562,7 @@ void efx_init_tx_queue_core_txq(struct efx_tx_queue *tx_queue) efx->n_tx_channels : 0)); } -int efx_setup_tc (struct net_device *net_dev,u8 num_tc) +int efx_setup_tc (struct net_device *net_dev,u32 handle,u8 num_tc) {struct efx_nic *efx =netdev_priv (net_dev);struct efx_channel *channel;
@@ -570,6 +570,9 @@ int efx_setup_tc(struct net_device *net_dev, u8 num_tc)unsigned tc;int rc; +if (handle !=TC_H_ROOT ) +return -EINVAL ; +if (efx_nic_rev (efx) <EFX_REV_FALCON_B0 || num_tc >EFX_MAX_TX_TC )return -EINVAL ;
drivers/net/ethernet/ti/netcp_core.c +4 -1
@@ -1831,13 +1831,16 @@ static u16 netcp_select_queue(struct net_device *dev, struct sk_buff *skb,return 0 ; } -static int netcp_setup_tc (struct net_device *dev,u8 num_tc) +static int netcp_setup_tc (struct net_device *dev,u32 handle,u8 num_tc) {int i;/* setup tc must be called under rtnl lock */ ASSERT_RTNL (); +if (handle !=TC_H_ROOT ) +return -EINVAL ; +/* Sanity-check the number of traffic classes requested */ if ((dev->real_num_tx_queues <=1 ) || (dev->real_num_tx_queues < num_tc))
include/linux/netdevice.h +1 -1
@@ -1148,7 +1148,7 @@ struct net_device_ops {int (*ndo_set_vf_rss_query_en)(struct net_device *dev,int vf,bool setting); -int (*ndo_setup_tc)(struct net_device *dev,u8 tc); +int (*ndo_setup_tc)(struct net_device *dev,u32 handle,u8 tc);#if IS_ENABLED (CONFIG_FCOE )int (*ndo_fcoe_enable)(struct net_device *dev);int (*ndo_fcoe_disable)(struct net_device *dev);
net/sched/sch_mqprio.c +3 -2
@@ -39,7 +39,7 @@ static void mqprio_destroy(struct Qdisc *sch) }if (priv->hw_owned && dev->netdev_ops->ndo_setup_tc) - dev->netdev_ops->ndo_setup_tc (dev,0 ); + dev->netdev_ops->ndo_setup_tc (dev, sch->handle,0 );else netdev_set_num_tc (dev,0 ); }
@@ -141,7 +141,8 @@ static int mqprio_init(struct Qdisc *sch, struct nlattr *opt)*/ if (qopt->hw) { priv->hw_owned =1 ; - err = dev->netdev_ops->ndo_setup_tc (dev, qopt->num_tc); + err = dev->netdev_ops->ndo_setup_tc (dev, sch->handle, + qopt->num_tc);if (err) goto err; }else {
RFC PATCH 2/7 net: rework setup_tc ndo op to consume general tc operand
In reply to John FastabendThis patch updates setup_tc so we can pass additional parameters into the ndo op in a generic way. To do this we provide structured union and type flag.
This lets each classifier and qdisc provide its own set of attributes without having to add new ndo ops or grow the signature of the callback.
--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 7 ++++--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h | 3 ++- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 8 ++++++-- drivers/net/ethernet/intel/fm10k/fm10k_netdev.c | 7 ++++--- drivers/net/ethernet/intel/i40e/i40e_main.c | 7 ++++--- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 7 ++++--- drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 7 ++++--- drivers/net/ethernet/sfc/efx.h | 3 ++- drivers/net/ethernet/sfc/tx.c | 9 ++++++--- drivers/net/ethernet/ti/netcp_core.c | 13 +++++++------ include/linux/netdevice.h | 20 +++++++++++++++++++- net/sched/sch_mqprio.c | 9 ++++++--- 12 files changed, 68 insertions(+), 32 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +4 -3
@@ -4268,11 +4268,12 @@ int bnx2x_setup_tc(struct net_device *dev, u8 num_tc)return 0 ; } -int __bnx2x_setup_tc (struct net_device *dev,u32 handle,u8 num_tc) +int __bnx2x_setup_tc (struct net_device *dev,u32 handle,__be16 proto, +struct tc_to_netdev *tc) { -if (handle !=TC_H_ROOT ) +if (handle !=TC_H_ROOT || tc->type !=TC_SETUP_MQPRIO )return -EINVAL ; -return bnx2x_setup_tc (dev, num_tc); +return bnx2x_setup_tc (dev, tc->tc); }/* called with rtnl_lock */
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h +2 -1
@@ -486,7 +486,8 @@ netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev);/* setup_tc callback */ int bnx2x_setup_tc (struct net_device *dev,u8 num_tc); -int __bnx2x_setup_tc (struct net_device *dev,u32 handle,u8 num_tc); +int __bnx2x_setup_tc (struct net_device *dev,u32 handle,__be16 proto, +struct tc_to_netdev *tc);int bnx2x_get_vf_config (struct net_device *dev,int vf,struct ifla_vf_info *ivi);
drivers/net/ethernet/broadcom/bnxt/bnxt.c +6 -2
@@ -5260,13 +5260,17 @@ static int bnxt_change_mtu(struct net_device *dev, int new_mtu)return 0 ; } -static int bnxt_setup_tc (struct net_device *dev,u32 handle,u8 tc) +static int bnxt_setup_tc (struct net_device *dev,u32 handle,__be16 proto, +struct tc_to_netdev *ntc) {struct bnxt *bp =netdev_priv (dev); +u8 tc; -if (handle !=TC_H_ROOT ) +if (handle !=TC_H_ROOT || ntc->type !=TC_SETUP_MQPRIO )return -EINVAL ; + tc = ntc->tc; +if (tc > bp->max_tc) {netdev_err (dev,"too many traffic classes requested: %d Max supported is %d\n" , tc, bp->max_tc);
drivers/net/ethernet/intel/fm10k/fm10k_netdev.c +4 -3
@@ -1190,12 +1190,13 @@ int fm10k_setup_tc(struct net_device *dev, u8 tc)return 0 ; } -static int __fm10k_setup_tc (struct net_device *dev,u32 handle,u8 tc) +static int __fm10k_setup_tc (struct net_device *dev,u32 handle,__be16 proto, +struct tc_to_netdev *tc) { -if (handle !=TC_H_ROOT ) +if (handle !=TC_H_ROOT || tc->type !=TC_SETUP_MQPRIO )return -EINVAL ; -return fm10k_setup_tc (dev, tc); +return fm10k_setup_tc (dev, tc->tc); }static int fm10k_ioctl (struct net_device *netdev,struct ifreq *ifr,int cmd)
drivers/net/ethernet/intel/i40e/i40e_main.c +4 -3
@@ -5298,11 +5298,12 @@ exit:return ret; } -static int __i40e_setup_tc (struct net_device *netdev,u32 handle,u8 tc) +static int __i40e_setup_tc (struct net_device *netdev,u32 handle,__be16 proto, +struct tc_to_netdev *tc) { -if (handle !=TC_H_ROOT ) +if (handle !=TC_H_ROOT || tc->type !=TC_SETUP_MQPRIO )return -EINVAL ; -return i40e_setup_tc (netdev, tc); +return i40e_setup_tc (netdev, tc->tc); }/**
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +4 -3
@@ -8167,13 +8167,14 @@ int ixgbe_setup_tc(struct net_device *dev, u8 tc)return 0 ; } -int __ixgbe_setup_tc (struct net_device *dev,u32 handle,u8 tc) +int __ixgbe_setup_tc (struct net_device *dev,u32 handle,__be16 proto, +struct tc_to_netdev *tc) {/* Only support egress tc setup for now */ -if (handle !=TC_H_ROOT ) +if (handle !=TC_H_ROOT || tc->type !=TC_SETUP_MQPRIO )return -EINVAL ; -return ixgbe_setup_tc (dev, tc); +return ixgbe_setup_tc (dev, tc->tc); }#ifdef CONFIG_PCI_IOV
drivers/net/ethernet/mellanox/mlx4/en_netdev.c +4 -3
@@ -69,12 +69,13 @@ int mlx4_en_setup_tc(struct net_device *dev, u8 up)return 0 ; } -static int __mlx4_en_setup_tc (struct net_device *dev,u32 handle,u8 up) +static int __mlx4_en_setup_tc (struct net_device *dev,u32 handle,__be16 proto, +struct tc_to_netdev *tc) { -if (handle !=TC_H_ROOT ) +if (handle !=TC_H_ROOT || tc->type !=TC_SETUP_MQPRIO )return -EINVAL ; -return mlx4_en_setup_tc (dev, up); +return mlx4_en_setup_tc (dev, tc->tc); }#ifdef CONFIG_RFS_ACCEL
drivers/net/ethernet/sfc/efx.h +2 -1
@@ -32,7 +32,8 @@ netdev_tx_t efx_hard_start_xmit(struct sk_buff *skb, struct net_device *net_dev);netdev_tx_t efx_enqueue_skb (struct efx_tx_queue *tx_queue,struct sk_buff *skb);void efx_xmit_done (struct efx_tx_queue *tx_queue,unsigned int index); -int efx_setup_tc (struct net_device *net_dev,u32 handle,u8 num_tc); +int efx_setup_tc (struct net_device *net_dev,u32 handle,__be16 proto, +struct tc_to_netdev *tc);unsigned int efx_tx_max_skb_descs (struct efx_nic *efx);extern unsigned int efx_piobuf_size;extern bool efx_separate_tx_channels;
drivers/net/ethernet/sfc/tx.c +6 -3
@@ -562,17 +562,20 @@ void efx_init_tx_queue_core_txq(struct efx_tx_queue *tx_queue) efx->n_tx_channels : 0)); } -int efx_setup_tc (struct net_device *net_dev,u32 handle,u8 num_tc) +int efx_setup_tc (struct net_device *net_dev,u32 handle,__be16 proto, +struct tc_to_netdev *ntc) {struct efx_nic *efx =netdev_priv (net_dev);struct efx_channel *channel;struct efx_tx_queue *tx_queue; -unsigned tc; +unsigned tc, num_tc;int rc; -if (handle !=TC_H_ROOT ) +if (handle !=TC_H_ROOT || ntc->type !=TC_SETUP_MQPRIO )return -EINVAL ; + num_tc = ntc->tc; +if (efx_nic_rev (efx) <EFX_REV_FALCON_B0 || num_tc >EFX_MAX_TX_TC )return -EINVAL ;
drivers/net/ethernet/ti/netcp_core.c +7 -6
@@ -1831,25 +1831,26 @@ static u16 netcp_select_queue(struct net_device *dev, struct sk_buff *skb,return 0 ; } -static int netcp_setup_tc (struct net_device *dev,u32 handle,u8 num_tc) +static int netcp_setup_tc (struct net_device *dev,u32 handle,__be16 proto, +struct tc_to_netdev tc) {int i;/* setup tc must be called under rtnl lock */ ASSERT_RTNL (); -if (handle !=TC_H_ROOT ) +if (handle !=TC_H_ROOT || tc->type !=TC_SETUP_MQPRIO )return -EINVAL ;/* Sanity-check the number of traffic classes requested */ if ((dev->real_num_tx_queues <=1 ) || - (dev->real_num_tx_queues < num_tc)) + (dev->real_num_tx_queues < tc->tc))return -EINVAL ;/* Configure traffic class to queue mappings */ -if (num_tc) { -netdev_set_num_tc (dev, num_tc); -for (i =0 ; i < num_tc; i++) +if (tc->tc) { +netdev_set_num_tc (dev, tc->tc); +for (i =0 ; i < tc->tc; i++)netdev_set_tc_queue (dev, i,1 , i); }else {netdev_reset_tc (dev);
include/linux/netdevice.h +19 -1
@@ -779,6 +779,21 @@ static inline bool netdev_phys_item_id_same(struct netdev_phys_item_id *a,typedef u16 (*select_queue_fallback_t )(struct net_device *dev,struct sk_buff *skb); +/* This structure holds attributes of qdisc and classifiers +* that are being passed to the netdevice through the setup_tc op. +*/ +enum { +TC_SETUP_MQPRIO , +}; + +struct tc_to_netdev { +unsigned int type; +union { +u8 tc; + }; +}; + +/* * This structure defines the management hooks for network devices. * The following hooks can be defined; unless noted otherwise, they are
@@ -1148,7 +1163,10 @@ struct net_device_ops {int (*ndo_set_vf_rss_query_en)(struct net_device *dev,int vf,bool setting); -int (*ndo_setup_tc)(struct net_device *dev,u32 handle,u8 tc); +int (*ndo_setup_tc)(struct net_device *dev, +u32 handle, +__be16 protocol, +struct tc_to_netdev *tc);#if IS_ENABLED (CONFIG_FCOE )int (*ndo_fcoe_enable)(struct net_device *dev);int (*ndo_fcoe_disable)(struct net_device *dev);
net/sched/sch_mqprio.c +6 -3
@@ -28,6 +28,7 @@ static void mqprio_destroy(struct Qdisc *sch) {struct net_device *dev =qdisc_dev (sch);struct mqprio_sched *priv =qdisc_priv (sch); +struct tc_to_netdev tc = {.type =TC_SETUP_MQPRIO };unsigned int ntx;if (priv->qdiscs) {
@@ -39,7 +40,7 @@ static void mqprio_destroy(struct Qdisc *sch) }if (priv->hw_owned && dev->netdev_ops->ndo_setup_tc) - dev->netdev_ops->ndo_setup_tc (dev, sch->handle,0 ); + dev->netdev_ops->ndo_setup_tc (dev, sch->handle,0 , &tc);else netdev_set_num_tc (dev,0 ); }
@@ -140,9 +141,11 @@ static int mqprio_init(struct Qdisc *sch, struct nlattr *opt)* supplied and verified mapping */ if (qopt->hw) { +struct tc_to_netdev tc = {.type =TC_SETUP_MQPRIO , + .tc = qopt->num_tc}; + priv->hw_owned =1 ; - err = dev->netdev_ops->ndo_setup_tc (dev, sch->handle, - qopt->num_tc); + err = dev->netdev_ops->ndo_setup_tc (dev, sch->handle,0 , &tc);if (err) goto err; }else {
RFC PATCH 3/7 net: sched: add cls_u32 offload hooks for netdevs
In reply to John FastabendThis patch allows netdev drivers to consume cls_u32 offloads via the ndo_setup_tc ndo op.
This works aligns with how network drivers have been doing qdisc offloads for mqprio.
--- include/linux/netdevice.h | 6 +++- include/net/pkt_cls.h | 33 ++++++++++++++++++++ net/sched/cls_u32.c | 73 ++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 109 insertions(+), 3 deletions(-)
include/linux/netdevice.h +5 -1
@@ -779,17 +779,21 @@ static inline bool netdev_phys_item_id_same(struct netdev_phys_item_id *a,typedef u16 (*select_queue_fallback_t )(struct net_device *dev,struct sk_buff *skb); -/* This structure holds attributes of qdisc and classifiers +/* These structures hold the attributes of qdisc and classifiers * that are being passed to the netdevice through the setup_tc op. */ enum {TC_SETUP_MQPRIO , +TC_SETUP_CLSU32 , }; +struct tc_cls_u32_offload ; +struct tc_to_netdev {unsigned int type;union {u8 tc; +struct tc_cls_u32_offload *cls_u32; }; };
include/net/pkt_cls.h +33 -0
@@ -358,4 +358,37 @@ tcf_match_indev(struct sk_buff *skb, int ifindex) }#endif /* CONFIG_NET_CLS_IND */ +struct tc_cls_u32_knode { +struct tcf_exts *exts; +u8 fshift; +u32 handle; +u32 val; +u32 mask; +u32 link_handle; +struct tc_u32_sel *sel; +}; + +struct tc_cls_u32_hnode { +u32 handle; +u32 prio; +unsigned int divisor; +}; + +enum { +TC_CLSU32_NEW_KNODE , +TC_CLSU32_REPLACE_KNODE , +TC_CLSU32_DELETE_KNODE , +TC_CLSU32_NEW_HNODE , +TC_CLSU32_REPLACE_HNODE , +}; + +struct tc_cls_u32_offload { +/* knode values */ +int command; +union { +struct tc_cls_u32_knode knode; +struct tc_cls_u32_hnode hnode; + }; +}; +#endif
net/sched/cls_u32.c +71 -2
116 lines not on this page · raw message
Re: [RFC PATCH 3/7] net: sched: add cls_u32 offload hooks for netdevs
Quoted 5 lines · John Fastabend
This patch allows netdev drivers to consume
cls_u32offloads via thendo_setup_tcndo op.This works aligns with how network drivers have been doing qdisc offloads for mqprio.
[...]
Quoted 14 lines
include/linux/netdevice.h +2
-1@@ -779,17 +779,21 @@ static inline bool netdev_phys_item_id_same(struct netdev_phys_item_id *a,typedef u16 (*select_queue_fallback_t )(struct net_device *dev,struct sk_buff *skb); -/* This structure holds attributes of qdisc and classifiers +/* These structures hold the attributes of qdisc and classifiers * that are being passed to the netdevice through the setup_tc op. */ enum {TC_SETUP_MQPRIO , +TC_SETUP_CLSU32 , };
include/linux/netdevice.h static inline bool netdev_phys_item_id_same(struct netdev_phys_item_id *a, · line 798
Quoted 10 lines
include/linux/netdevice.h +3
-0+struct tc_cls_u32_offload ; +struct tc_to_netdev {unsigned int type;union {u8 tc; +struct tc_cls_u32_offload *cls_u32; }; };
So under this approach we're making the HW driver u32 aware. Do we really want to go there?
The flow-dissector + actions structure way of describing matching and actions maybe had some
drawbacks but it's not affiliated with a specific networking component (here TC/U32). When we look
fwd do we expect everything (netfilter offloads for example) to be expressed in u32 terms?
Or.
Re: [RFC PATCH 3/7] net: sched: add cls_u32 offload hooks for netdevs
Quoted 24 lines · Or Gerlitz
Quoted 5 lines · John Fastabend
This patch allows netdev drivers to consume
cls_u32offloads via thendo_setup_tcndo op.This works aligns with how network drivers have been doing qdisc offloads for mqprio.
[...]
Quoted 15 lines
include/linux/netdevice.h +2
-1@@ -779,17 +779,21 @@ static inline bool netdev_phys_item_id_same(struct netdev_phys_item_id *a,typedef u16 (*select_queue_fallback_t )(struct net_device *dev,struct sk_buff *skb); -/* This structure holds attributes of qdisc and classifiers +/* These structures hold the attributes of qdisc and classifiers * that are being passed to the netdevice through the setup_tc op. */ enum {TC_SETUP_MQPRIO , +TC_SETUP_CLSU32 , };
Quoted 13 lines
include/linux/netdevice.h static inline bool netdev_phys_item_id_same(struct netdev_phys_item_id *a, · line 798
Quoted 9 lines
include/linux/netdevice.h +3
-0+struct tc_cls_u32_offload ; +struct tc_to_netdev {unsigned int type;union {u8 tc; +struct tc_cls_u32_offload *cls_u32; }; };So under this approach we're making the HW driver u32 aware. Do we really want to go there?
Yes, I'm not convinced writing the universal language X to arbitrary hardware is worth the complexity/cost at the moment. I already started writing this universal block of code and it gets a bit complex to do it right. Anyways none of this is exposed via UAPI so it can be conslidated reworked as needed. Also I'm not to keen on going from tc/netfilter/etc to language X (hw IR) to hardware when the block of code to jump from u32 or flower to hardware is so simple. I added flower support to the driver with about 100lines of code fwiw I'll send the patch out later today, sure I skipped populating all the fields by breaking out of some case statements but not that many.
I don't mind opening up some helper functions if you like my backend structures. But anyways most the hard work is programming the hardware and hoping someone did silicon validation anyways imo.
Quoted 6 lines
The flow-dissector + actions structure way of describing matching and actions maybe had some
drawbacks but it's not affiliated with a specific networking component (here TC/U32). When we look
fwd do we expect everything (netfilter offloads for example) to be expressed in u32 terms?
I'm a bit tired of speculating about what_ifs when we see the netfilter offload code lets take a look at consolidating. For now I have code that _works_.
Quoted 3 lines
Or.
Re: [RFC PATCH 3/7] net: sched: add cls_u32 offload hooks for netdevs
On Tue, Feb 2, 2016 at 6:42 PM, John Fastabend
<[email protected]> > [..] I added
Quoted 2 lines
flower support to the driver with about 100lines of code fwiw I'll send the patch out later today,
that would be very helpful, would appreciate if you post the code that supports flower to the list or @ your github
Quoted 2 lines
sure I skipped populating all the
fields by breaking out of some case statements but not that many.
RFC PATCH 4/7 net: add tc offload feature flag
In reply to John FastabendIts useful to turn off the qdisc offload feature at a per device level. This gives us a big hammer to enable/disable offloading. More fine grained control (i.e. per rule) may be supported later.
--- include/linux/netdev_features.h | 3 +++ net/core/ethtool.c | 1 + 2 files changed, 4 insertions(+)
include/linux/netdev_features.h +3 -0
@@ -67,6 +67,8 @@ enum {NETIF_F_HW_L2FW_DOFFLOAD_BIT ,/* Allow L2 Forwarding in Hardware */ NETIF_F_BUSY_POLL_BIT ,/* Busy poll */ +NETIF_F_HW_TC_BIT ,/* Offload TC infrastructure */ +/* * Add your fresh new feature above and remember to update * netdev_features_strings[] in net/core/ethtool.c and maybe
@@ -124,6 +126,7 @@ enum {#define NETIF_F_HW_VLAN_STAG_TX __NETIF_F(HW_VLAN_STAG_TX)#define NETIF_F_HW_L2FW_DOFFLOAD __NETIF_F(HW_L2FW_DOFFLOAD)#define NETIF_F_BUSY_POLL __NETIF_F(BUSY_POLL) +#define NETIF_F_HW_TC __NETIF_F(HW_TC)#define for_each_netdev_feature (mask_addr, bit) \ for_each_set_bit(bit, (unsigned long *)mask_addr, NETDEV_FEATURE_COUNT)
net/core/ethtool.c +1 -0
@@ -98,6 +98,7 @@ static const char netdev_features_strings[NETDEV_FEATURE_COUNT][ETH_GSTRING_LEN] [NETIF_F_RXALL_BIT] = "rx-all", [NETIF_F_HW_L2FW_DOFFLOAD_BIT] = "l2-fwd-offload", [NETIF_F_BUSY_POLL_BIT] = "busy-poll", + [NETIF_F_HW_TC_BIT] = "hw-tc-offload", }; static const char
RFC PATCH 5/7 net: tc: helper functions to query action types
In reply to John FastabendThis is a helper function drivers can use to learn if the action type is a drop action.
--- include/net/tc_act/tc_gact.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
include/net/tc_act/tc_gact.h +14 -0
@@ -2,6 +2,7 @@#define __NET_TC_GACT_H#include <net/act_api.h> +#include <linux/tc_act/tc_gact.h> struct tcf_gact {struct tcf_common common;
@@ -15,4 +16,17 @@ struct tcf_gact {#define to_gact (a) \ container_of(a->priv, struct tcf_gact, common) +static inline bool is_tcf_gact_dropped (const struct tc_action *a) +{ +struct tcf_gact *gact; + +if (a->ops && a->ops->type !=TCA_ACT_GACT ) +return false; + + gact = a->priv; +if (gact->tcf_action ==TC_ACT_SHOT ) +return true; + +return false; +}#endif /* __NET_TC_GACT_H */
RFC PATCH 6/7 net: ixgbe: add minimal parser details for ixgbe
In reply to John FastabendThis adds an ixgbe data structure that is used to determine what headers:fields can be matched and in what order they are supported.
For hardware devices this can be a bit tricky because typically only pre-programmed (firmware, ucode, rtl) parse graphs will be supported and we don't yet have an interface to change these from the OS. So its sort of a you get whatever your friendly vendor provides affair at the moment.
In the future we can add the get routines and set routines to update this data structure. One interesting thing to note here is the data structure here identifies ethernet, ip, and tcp fields without having to hardcode them as enumerations or use other identifiers.
--- drivers/net/ethernet/intel/ixgbe/ixgbe_model.h | 110 ++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 drivers/net/ethernet/intel/ixgbe/ixgbe_model.h
drivers/net/ethernet/intel/ixgbe/ixgbe_model.h new file +110 -0
@@ -0,0 +1,110 @@ +/******************************************************************************* + +Intel 10 Gigabit PCI Express Linux driver +Copyright(c) 2016 Intel Corporation. + +This program is free software; you can redistribute it and/or modify it +under the terms and conditions of the GNU General Public License, +version 2, as published by the Free Software Foundation. + +This program is distributed in the hope it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +more details. + +You should have received a copy of the GNU General Public License along with +this program; if not, write to the Free Software Foundation, Inc., +51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + +The full GNU General Public License is included in this distribution in +the file called "COPYING". + +Contact Information: +Linux NICS <[email protected]> +e1000-devel Mailing List <[email protected]> +Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + +*******************************************************************************/ + +#ifndef _IXGBE_MODEL_H_ +#define _IXGBE_MODEL_H_ + +#include "ixgbe.h" +#include "ixgbe_type.h" + +struct ixgbe_mat_field { +unsigned int off; +unsigned int mask; +int (*val)(struct ixgbe_fdir_filter *input, +union ixgbe_atr_input *mask, +__u32 val,__u32 m); +int link; +}; + +static inline int ixgbe_mat_prgm_sip (struct ixgbe_fdir_filter *input, +union ixgbe_atr_input *mask, +__u32 val,__u32 m) +{ + input->filter.formatted.src_ip[0 ] = val; + mask->formatted.src_ip[0 ] = m; +return 0 ; +} + +static inline int ixgbe_mat_prgm_dip (struct ixgbe_fdir_filter *input, +union ixgbe_atr_input *mask, +__u32 val,__u32 m) +{ + input->filter.formatted.dst_ip[0 ] = val; + mask->formatted.dst_ip[0 ] = m; +return 0 ; +} + +static struct ixgbe_mat_field ixgbe_ipv4_fields[] = { + { .off =12 , .mask =-1 , .val = ixgbe_mat_prgm_sip, .link =0 }, + { .off =16 , .mask =-1 , .val = ixgbe_mat_prgm_dip, .link =0 }, + { .val =NULL }/* terminal node */ +}; + +static inline int ixgbe_mat_prgm_sport (struct ixgbe_fdir_filter *input, +union ixgbe_atr_input *mask, +__u32 val,__u32 m) +{ + input->filter.formatted.src_port = val &0xffff ; + mask->formatted.src_port = m &0xffff ; +return 0 ; +}; + +static inline int ixgbe_mat_prgm_dport (struct ixgbe_fdir_filter *input, +union ixgbe_atr_input *mask, +__u32 val,__u32 m) +{ + input->filter.formatted.dst_port = val &0xffff ; + mask->formatted.dst_port = m &0xffff ; +return 0 ; +}; + +static struct ixgbe_mat_field ixgbe_tcp_fields[] = { + {.off =0 , .mask =0xffff , .val = ixgbe_mat_prgm_sport, .link =-1 }, + {.off =2 , .mask =0xffff , .val = ixgbe_mat_prgm_dport, .link =-1 }, + { .val =NULL }/* terminal node */ +}; + +struct ixgbe_nexthdr { +/* offset, shift, and mask of position to next header */ +unsigned int o; +__u32 s; +__u32 m; +/* match criteria to make this jump*/ +unsigned int off; +__u32 val; +__u32 mask; +/* location of jump to make */ +struct ixgbe_mat_field *jump; +}; + +static struct ixgbe_nexthdr ixgbe_ipv4_jumps[] = { + { .o =0 , .s =6 , .m =0xf , + .off =8 , .val =0x600 , .mask =0xff00 , .jump = ixgbe_tcp_fields}, + { .jump =NULL }/* terminal node */ +}; +#endif /* _IXGBE_MODEL_H_ */
Re: [RFC PATCH 6/7] net: ixgbe: add minimal parser details for ixgbe
Quoted 9 lines · John Fastabend
This adds an ixgbe data structure that is used to determine what headers:fields can be matched and in what order they are supported.
For hardware devices this can be a bit tricky because typically only pre-programmed (firmware, ucode, rtl) parse graphs will be supported and we don't yet have an interface to change these from the OS. So its sort of a you get whatever your friendly vendor provides affair at the moment.
Quoted 5 lines
In the future we can add the get routines and set routines to update this data structure. One interesting thing to note here is the data structure here identifies ethernet, ip, and tcp fields without having to hardcode them as enumerations or use other identifiers.
Maybe for the current state this patch (or the most of it) can be made generic and provided in a way that multiple HW drivers can use it?
Re: [RFC PATCH 6/7] net: ixgbe: add minimal parser details for ixgbe
Quoted 10 lines · Or Gerlitz
Quoted 9 lines · John Fastabend
This adds an ixgbe data structure that is used to determine what headers:fields can be matched and in what order they are supported.
For hardware devices this can be a bit tricky because typically only pre-programmed (firmware, ucode, rtl) parse graphs will be supported and we don't yet have an interface to change these from the OS. So its sort of a you get whatever your friendly vendor provides affair at the moment.
Quoted 9 lines
Quoted 5 lines
In the future we can add the get routines and set routines to update this data structure. One interesting thing to note here is the data structure here identifies ethernet, ip, and tcp fields without having to hardcode them as enumerations or use other identifiers.
Maybe for the current state this patch (or the most of it) can be made generic and provided in a way that multiple HW drivers can use it?
If you want the structs we can put them in a helper lib but the main code is two for loops to catch the keys and an if block to catch the nexthdr code mixed with a bunch of code to program the specific device. Its just not that helpful to other drivers.
.John
RFC PATCH 7/7 net: ixgbe: add support for tc_u32 offload
In reply to John FastabendThis adds initial support for offloading the u32 tc classifier. This initial implementation only implements a few base matches and actions to illustrate the use of the infrastructure patches.
However it is an interesting subset because it handles the u32 next hdr logic to correctly map tcp packets from ip headers using the ihl and protocol fields. After this is accepted we can extend the match and action fields easily by updating the model header file.
Also only the drop action is supported initially.
--- drivers/net/ethernet/intel/ixgbe/ixgbe.h | 3 drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 6 - drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 188 ++++++++++++++++++++++ 3 files changed, 190 insertions(+), 7 deletions(-)
drivers/net/ethernet/intel/ixgbe/ixgbe.h +3 -0
@@ -925,6 +925,9 @@ s32 ixgbe_fdir_erase_perfect_filter_82599(struct ixgbe_hw *hw, u16 soft_id);void ixgbe_atr_compute_perfect_hash_82599 (union ixgbe_atr_input *input,union ixgbe_atr_input *mask); +int ixgbe_update_ethtool_fdir_entry (struct ixgbe_adapter *adapter, +struct ixgbe_fdir_filter *input, +u16 sw_idx);void ixgbe_set_rx_mode (struct net_device *netdev);#ifdef CONFIG_IXGBE_DCB void ixgbe_set_rx_drop_en (struct ixgbe_adapter *adapter);
drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c +3 -3
@@ -2490,9 +2490,9 @@ static int ixgbe_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd,return ret; } -static int ixgbe_update_ethtool_fdir_entry (struct ixgbe_adapter *adapter, -struct ixgbe_fdir_filter *input, -u16 sw_idx) +int ixgbe_update_ethtool_fdir_entry (struct ixgbe_adapter *adapter, +struct ixgbe_fdir_filter *input, +u16 sw_idx) {struct ixgbe_hw *hw = &adapter->hw;struct hlist_node *node2;
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +184 -4
222 lines not on this page · raw message
David Miller
maintainerRe: [RFC PATCH 7/7] net: ixgbe: add support for tc_u32 offload
From: John Fastabend <[email protected]>
Date: Sun, 31 Jan 2016 17:53:10 -0800
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c int ixgbe_setup_tc(struct net_device *dev, u8 tc) · line 8236
Quoted 1 line
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +1
-0+ ixgbe_jump_tables[uhtid] = nexthdr->jump;
I can't figure out what protects concurrent accesses to this shared ixgbe_jump_table[]. Is RTNL held here? If so it's likely that GFP_ATOMIC can be changed to GFP_KERNEL in this function.
Re: [RFC PATCH 7/7] net: ixgbe: add support for tc_u32 offload
Quoted 10 lines · David Miller
From: John Fastabend <[email protected]>
Date: Sun, 31 Jan 2016 17:53:10 -0800drivers/net/ethernet/intel/ixgbe/ixgbe_main.c int ixgbe_setup_tc(struct net_device *dev, u8 tc) · line 8236
Quoted 1 line
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +1
-0+ ixgbe_jump_tables[uhtid] = nexthdr->jump;I can't figure out what protects concurrent accesses to this shared ixgbe_jump_table[]. Is RTNL held here? If so it's likely that
GFP_ATOMICcan be changed toGFP_KERNELin this function.
This is only called from tc_ctl_tfilter which is wrapped in the rtnl_lock as you suspected.
Thanks for the catch I'll convert it to GFP_KERNEL along with the other spot I copy pasted the GFP_ATOMIC code from.
.John
Jiri Pirko
maintainerQuoted 30 lines · Mon, Feb 01, 2016 at 02:48:32AM CET, [email protected] wrote:
I was waiting for net-next to open to submit this but it seems like a good idea to get an RFC out there for folks to start looking over.
This extends the
setup_tcframework so it can support more than just the mqprio offload and push other classifiers and qdiscs into the hardware. The series here targets the u32 classifier and ixgbe driver. I worked out the u32 classifier because it is protocol oblivious and aligns with multiple hardware devices I have access to. I did an initial implementation on ixgbe because (a) I have one in my box (b) its a stable driver and (c) it is relatively simple compared to the other devices I have here but still has enough flexibility to exercise the features ofcls_u32.I intentionally limited the scope of this series to the basic feature set. Specifically this uses a 'big hammer' feature bit to do the offload or not. If the bit is set you get offloaded rules if it is not then rules will not be offloaded. If we can agree on this patch series there are some more patches on my queue we can talk about to make the offload decision per rule using flags similar to how we do l2 mac updates. Additionally the error strategy can be improved to be hard aborting, log and continue, etc. I think these are nice to have improvements but shouldn't block this series. I am working on similar support for the other Intel devices now as well namely i40e and fm10k.
Also in the future work bin by adding
get_parse_graphandset_parse_graphattributes as in my previousflow_apiwork we can build programmable devices and programmatically learn when rules can or can not be loaded into the hardware.
Quoted 6 lines
Note this series is on a slightly behind net-next stack I think it should apply to the latest but I haven't updated the series for awhile I'll do that soon I was sort of waiting for net-next to open to do this.
Any comments/feedback appreciated.
I like this patchset. I gave it a quick peek and I it looks to me like the correct way to go. There are couple of things needed to be decided, as you described them (e. g. per-rule offload) - we should discuss them on netdev conference. I hope you will be there.
I curious about how do you plan to expose the parse graphs get/set ops...
Quoted 42 lines
Thanks,
John---
John Fastabend (7):
net: rework ndo tc op to consume additional qdisc handle parameter
net: reworksetup_tcndo op to consume general tc operand
net: sched: addcls_u32offload hooks for netdevs
net: add tc offload feature flag
net: tc: helper functions to query action types
net: ixgbe: add minimal parser details for ixgbe
net: ixgbe: add support fortc_u32offloaddrivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 8 + drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h | 2 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 2 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 9 + drivers/net/ethernet/intel/fm10k/fm10k_netdev.c | 11 + drivers/net/ethernet/intel/i40e/i40e_main.c | 10 + drivers/net/ethernet/intel/ixgbe/ixgbe.h | 3 drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 6 - drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 198 ++++++++++++++++++++++ drivers/net/ethernet/intel/ixgbe/ixgbe_model.h | 110 ++++++++++++ drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 13 + drivers/net/ethernet/sfc/efx.h | 3 drivers/net/ethernet/sfc/tx.c | 10 + drivers/net/ethernet/ti/netcp_core.c | 14 +- include/linux/netdev_features.h | 3 include/linux/netdevice.h | 24 +++ include/net/pkt_cls.h | 33 ++++ include/net/tc_act/tc_gact.h | 14 ++ net/core/ethtool.c | 1 net/sched/cls_u32.c | 73 ++++++++ net/sched/sch_mqprio.c | 8 + 21 files changed, 529 insertions(+), 26 deletions(-)create mode 100644
drivers/net/ethernet/intel/ixgbe/ixgbe_model.h--
Signature
Quoted 36 lines · Jiri Pirko
Quoted 35 lines · Mon, Feb 01, 2016 at 02:48:32AM CET, [email protected] wrote:
I was waiting for net-next to open to submit this but it seems like a good idea to get an RFC out there for folks to start looking over.
This extends the
setup_tcframework so it can support more than just the mqprio offload and push other classifiers and qdiscs into the hardware. The series here targets the u32 classifier and ixgbe driver. I worked out the u32 classifier because it is protocol oblivious and aligns with multiple hardware devices I have access to. I did an initial implementation on ixgbe because (a) I have one in my box (b) its a stable driver and (c) it is relatively simple compared to the other devices I have here but still has enough flexibility to exercise the features ofcls_u32.I intentionally limited the scope of this series to the basic feature set. Specifically this uses a 'big hammer' feature bit to do the offload or not. If the bit is set you get offloaded rules if it is not then rules will not be offloaded. If we can agree on this patch series there are some more patches on my queue we can talk about to make the offload decision per rule using flags similar to how we do l2 mac updates. Additionally the error strategy can be improved to be hard aborting, log and continue, etc. I think these are nice to have improvements but shouldn't block this series. I am working on similar support for the other Intel devices now as well namely i40e and fm10k.
Also in the future work bin by adding
get_parse_graphandset_parse_graphattributes as in my previousflow_apiwork we can build programmable devices and programmatically learn when rules can or can not be loaded into the hardware.Note this series is on a slightly behind net-next stack I think it should apply to the latest but I haven't updated the series for awhile I'll do that soon I was sort of waiting for net-next to open to do this.
Quoted 4 lines
Quoted 1 line
Any comments/feedback appreciated.
I like this patchset. I gave it a quick peek and I it looks to me like the correct way to go. There are couple of things needed to be decided
Great.
,
Quoted 3 lines
as you described them (e. g. per-rule offload) - we should discuss them on netdev conference. I hope you will be there.
I'll be at the conference so we can discuss it there. Although even without the per-rule flow this set is useful. Like I noted I view that as an optimization and its much more useful on a NIC where host traffic is the norm vs a switch where host traffic is most likely the exception.
Quoted 1 line
I curious about how do you plan to expose the parse graphs get/set ops...
The current stack of patches I have on my dev box use a new netlink handler. ethtool could work as well but my preference is netlink in this case.