Flower flow merging
Subsystems (3)
cover Flower flow merging
John Hurley says,
These patches deal with 'implicit recirculation' on the NFP. This is a firmware feature whereby a packet egresses to an 'internal' port meaning that it will recirculate back to the header extract phase with the 'internal' port now marked as its ingress port. This internal port can then be matched on by another rule. This process simulates how OvS datapath outputs to an internal port. The FW traces the packet's recirculation route and sends a 'merge hint' to the driver telling it which flows it matched against. The driver can then decide if these flows can be merged to a single rule and offloaded.
The patches deal with the following issues:
- assigning/freeing IDs to/from each of these new internal ports
- offloading rules that match on internal ports
- offloading neighbour table entries whose egress port is internal
- handling fallback traffic with an internal port as ingress
- using merge hints to create 'faster path' flows and tracking stats etc.
John Hurley (11):
nfp: flower: turn on recirc and merge hint support in firmware
nfp: flower: allow offloading of matches on 'internal' ports
nfp: allow fallback packets from non-reprs
nfp: flower: support fallback packets from internal ports
nfp: flower: allow tunnels to output to internal port
nfp: flower: get flows by host context
nfp: flower: handle merge hint messages
nfp: flower: validate merge hint flows
nfp: flower: generate merge flow rule
nfp: flower: support stats update for merge flows
nfp: flower: offload merge flows
drivers/net/ethernet/netronome/nfp/abm/main.c | 5 +- drivers/net/ethernet/netronome/nfp/flower/cmsg.c | 55 +- drivers/net/ethernet/netronome/nfp/flower/cmsg.h | 19 + drivers/net/ethernet/netronome/nfp/flower/main.c | 149 ++++- drivers/net/ethernet/netronome/nfp/flower/main.h | 69 +++ drivers/net/ethernet/netronome/nfp/flower/match.c | 9 +- .../net/ethernet/netronome/nfp/flower/metadata.c | 117 +++- .../net/ethernet/netronome/nfp/flower/offload.c | 606 ++++++++++++++++++++- .../ethernet/netronome/nfp/flower/tunnel_conf.c | 11 +- drivers/net/ethernet/netronome/nfp/nfp_app.h | 13 +- .../net/ethernet/netronome/nfp/nfp_net_common.c | 16 +- 11 files changed, 1016 insertions(+), 53 deletions(-)
Signature · 1 line
2.11.0
PATCH 1/11 nfp: flower: turn on recirc and merge hint support in firmware
From: John Hurley <[email protected]>
Write to a FW symbol to indicate that the driver supports flow merging. If this symbol does not exist then flow merging and recirculation is not supported on the FW. If support is available, add a stub to deal with FW to kernel merge hint messages.
Full flow merging requires the firmware to support of flow mods. If it does not, then do not attempt to 'turn on' flow merging.
--- drivers/net/ethernet/netronome/nfp/flower/cmsg.c | 5 +++++ drivers/net/ethernet/netronome/nfp/flower/cmsg.h | 1 + drivers/net/ethernet/netronome/nfp/flower/main.c | 17 +++++++++++++++++ drivers/net/ethernet/netronome/nfp/flower/main.h | 2 ++ 4 files changed, 25 insertions(+)
drivers/net/ethernet/netronome/nfp/flower/cmsg.c +5 -0
@@ -222,6 +222,10 @@ nfp_flower_cmsg_process_one_rx(struct nfp_app *app, struct sk_buff *skb)case NFP_FLOWER_CMSG_TYPE_PORT_MOD :nfp_flower_cmsg_portmod_rx (app, skb);break ; +case NFP_FLOWER_CMSG_TYPE_MERGE_HINT : +if (app_priv->flower_ext_feats &NFP_FL_FEATS_FLOW_MERGE ) +break ; + goto err_default;case NFP_FLOWER_CMSG_TYPE_NO_NEIGH :nfp_tunnel_request_route (app, skb);break ;
@@ -235,6 +239,7 @@ nfp_flower_cmsg_process_one_rx(struct nfp_app *app, struct sk_buff *skb) }/* fall through */ default : +err_default:nfp_flower_cmsg_warn (app,"Cannot handle invalid repr control type %u\n" , type); goto out;
drivers/net/ethernet/netronome/nfp/flower/cmsg.h +1 -0
@@ -407,6 +407,7 @@ enum nfp_flower_cmsg_type_port {NFP_FLOWER_CMSG_TYPE_PORT_REIFY =6 ,NFP_FLOWER_CMSG_TYPE_MAC_REPR =7 ,NFP_FLOWER_CMSG_TYPE_PORT_MOD =8 , +NFP_FLOWER_CMSG_TYPE_MERGE_HINT =9 ,NFP_FLOWER_CMSG_TYPE_NO_NEIGH =10 ,NFP_FLOWER_CMSG_TYPE_TUN_MAC =11 , NFP_FLOWER_CMSG_TYPE_ACTIVE_TUNS = 12,
drivers/net/ethernet/netronome/nfp/flower/main.c +17 -0
@@ -641,11 +641,28 @@ static int nfp_flower_init(struct nfp_app *app) goto err_cleanup_metadata; } +if (app_priv->flower_ext_feats &NFP_FL_FEATS_FLOW_MOD ) { +/* Tell the firmware that the driver supports flow merging. */ + err =nfp_rtsym_write_le (app->pf->rtbl, +"_abi_flower_merge_hint_enable" ,1 ); +if (!err) + app_priv->flower_ext_feats |=NFP_FL_FEATS_FLOW_MERGE ; +else if (err == -ENOENT ) +nfp_warn (app->cpp,"Flow merge not supported by FW.\n" ); +else + goto err_lag_clean; + }else { +nfp_warn (app->cpp,"Flow mod/merge not supported by FW.\n" ); + } +INIT_LIST_HEAD (&app_priv->indr_block_cb_priv);INIT_LIST_HEAD (&app_priv->non_repr_priv);return 0 ; +err_lag_clean: +if (app_priv->flower_ext_feats &NFP_FL_FEATS_LAG ) +nfp_flower_lag_cleanup (&app_priv->nfp_lag); err_cleanup_metadata:nfp_flower_metadata_cleanup (app); err_free_app_priv:
drivers/net/ethernet/netronome/nfp/flower/main.h +2 -0
@@ -39,6 +39,8 @@ struct nfp_app;#define NFP_FL_NBI_MTU_SETTING BIT(1)#define NFP_FL_FEATS_GENEVE_OPT BIT(2)#define NFP_FL_FEATS_VLAN_PCP BIT(3) +#define NFP_FL_FEATS_FLOW_MOD BIT(5) +#define NFP_FL_FEATS_FLOW_MERGE BIT(30)#define NFP_FL_FEATS_LAG BIT(31)struct nfp_fl_mask_id {
Signature · 1 line
2.11.0
PATCH 2/11 nfp: flower: allow offloading of matches on 'internal' ports
In reply to Simon HormanFrom: John Hurley <[email protected]>
Recent FW modifications allow the offloading of non repr ports. These ports exist internally on the NFP. So if a rule outputs to an 'internal' port, then the packet will recirculate back into the system but will now have this internal port as it's incoming port. These ports are indicated by a specific type field combined with an 8 bit port id.
Add private app data to assign additional port ids for use in offloads. Provide functions to lookup or create new ids when a rule attempts to match on an internal netdev - the only internal netdevs currently supported are of type openvswitch. Have a netdev notifier to release port ids on netdev unregister.
OvS offloads rules that match on internal ports as TC egress filters. Ensure that such rules are accepted by the driver.
--- drivers/net/ethernet/netronome/nfp/flower/cmsg.h | 7 ++ drivers/net/ethernet/netronome/nfp/flower/main.c | 112 ++++++++++++++++++++- drivers/net/ethernet/netronome/nfp/flower/main.h | 30 ++++++ drivers/net/ethernet/netronome/nfp/flower/match.c | 9 +- .../net/ethernet/netronome/nfp/flower/offload.c | 4 +- 5 files changed, 153 insertions(+), 9 deletions(-)
drivers/net/ethernet/netronome/nfp/flower/cmsg.h +7 -0
@@ -474,6 +474,13 @@ enum nfp_flower_cmsg_port_vnic_type {#define NFP_FLOWER_CMSG_PORT_PCIE_Q GENMASK(5, 0)#define NFP_FLOWER_CMSG_PORT_PHYS_PORT_NUM GENMASK(7, 0) +static inline u32 nfp_flower_internal_port_get_port_id (u8 internal_port) +{ +return FIELD_PREP (NFP_FLOWER_CMSG_PORT_PHYS_PORT_NUM , internal_port) | +FIELD_PREP (NFP_FLOWER_CMSG_PORT_TYPE , +NFP_FLOWER_CMSG_PORT_TYPE_OTHER_PORT ); +} +static inline u32 nfp_flower_cmsg_phys_port (u8 phys_port) { return FIELD_PREP(NFP_FLOWER_CMSG_PORT_PHYS_PORT_NUM, phys_port) |
drivers/net/ethernet/netronome/nfp/flower/main.c +109 -3
145 lines not on this page · raw message
drivers/net/ethernet/netronome/nfp/flower/main.h +30 -0
@@ -117,6 +117,16 @@ struct nfp_fl_lag { };/** +* struct nfp_fl_internal_ports - Flower APP priv data for additional ports +* @port_ids: Assignment of ids to any additional ports +* @lock: Lock for extra ports list +*/ +struct nfp_fl_internal_ports { +struct idr port_ids; +spinlock_t lock; +}; + +/** * struct nfp_flower_priv - Flower APP per-vNIC priv data * @app: Back pointer to app * @nn: Pointer to vNIC
@@ -145,6 +155,7 @@ struct nfp_fl_lag {* @non_repr_priv: List of offloaded non-repr ports and their priv data * @active_mem_unit: Current active memory unit for flower rules * @total_mem_units: Total number of available memory units for flower rules +* @internal_ports: Internal port ids used in offloaded rules */ struct nfp_flower_priv {struct nfp_app *app;
@@ -171,6 +182,7 @@ struct nfp_flower_priv {struct list_head non_repr_priv;unsigned int active_mem_unit;unsigned int total_mem_units; +struct nfp_fl_internal_ports internal_ports; };/**
@@ -249,6 +261,22 @@ struct nfp_fl_stats_frame {__be64 stats_cookie; }; +static inline bool +nfp_flower_internal_port_can_offload (struct nfp_app *app, +struct net_device *netdev) +{ +struct nfp_flower_priv *app_priv = app->priv; + +if (!(app_priv->flower_ext_feats &NFP_FL_FEATS_FLOW_MERGE )) +return false; +if (!netdev->rtnl_link_ops) +return false; +if (!strcmp (netdev->rtnl_link_ops->kind,"openvswitch" )) +return true; + +return false; +} +int nfp_flower_metadata_init (struct nfp_app *app,u64 host_ctx_count,unsigned int host_ctx_split);void nfp_flower_metadata_cleanup (struct nfp_app *app);
@@ -313,4 +341,6 @@ void __nfp_flower_non_repr_priv_put(struct nfp_flower_non_repr_priv *non_repr_priv);void nfp_flower_non_repr_priv_put (struct nfp_app *app,struct net_device *netdev); +u32 nfp_flower_get_port_id_from_netdev (struct nfp_app *app, +struct net_device *netdev);#endif
drivers/net/ethernet/netronome/nfp/flower/match.c +4 -5
@@ -326,13 +326,12 @@ int nfp_flower_compile_flow_match(struct nfp_app *app,struct nfp_fl_payload *nfp_flow, enum nfp_flower_tun_type tun_type) { - u32 cmsg_port = 0; + u32 port_id;int err;u8 *ext;u8 *msk; -if (nfp_netdev_is_nfp_repr (netdev)) - cmsg_port =nfp_repr_get_port_id (netdev); + port_id =nfp_flower_get_port_id_from_netdev (app, netdev);memset (nfp_flow->unmasked_data,0 , key_ls->key_size);memset (nfp_flow->mask_data,0 , key_ls->key_size);
@@ -358,13 +357,13 @@ int nfp_flower_compile_flow_match(struct nfp_app *app,/* Populate Exact Port data. */ err =nfp_flower_compile_port ((struct nfp_flower_in_port *)ext, - cmsg_port, false, tun_type); + port_id, false, tun_type);if (err)return err;/* Populate Mask Port Data. */ err =nfp_flower_compile_port ((struct nfp_flower_in_port *)msk, - cmsg_port, true, tun_type); + port_id, true, tun_type);if (err)return err;
drivers/net/ethernet/netronome/nfp/flower/offload.c +3 -1
@@ -682,7 +682,9 @@ nfp_flower_setup_indr_tc_block(struct net_device *netdev, struct nfp_app *app,struct nfp_flower_priv *priv = app->priv;int err; -if (f->binder_type !=TCF_BLOCK_BINDER_TYPE_CLSACT_INGRESS ) +if (f->binder_type !=TCF_BLOCK_BINDER_TYPE_CLSACT_INGRESS && + !(f->binder_type ==TCF_BLOCK_BINDER_TYPE_CLSACT_EGRESS && +nfp_flower_internal_port_can_offload (app, netdev)))return -EOPNOTSUPP ;switch (f->command) {
Signature · 1 line
2.11.0
PATCH 4/11 nfp: flower: support fallback packets from internal ports
In reply to Simon HormanFrom: John Hurley <[email protected]>
FW may receive a packet with its ingress port marked as an internal port. If a rule does not exist to match on this port, the packet will be sent to the NFP driver. Modify the flower app to detect packets from such internal ports and convert the ingress port to the correct kernel space netdev.
At this point, it is assumed that fallback packets from internal ports are to be sent out said port. Therefore, set the redir_egress bool to true on detection of these ports.
--- drivers/net/ethernet/netronome/nfp/flower/main.c | 26 ++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-)
drivers/net/ethernet/netronome/nfp/flower/main.c +24 -2
@@ -91,6 +91,19 @@ u32 nfp_flower_get_port_id_from_netdev(struct nfp_app *app,return 0 ; } +static struct net_device * +nfp_flower_get_netdev_from_internal_port_id (struct nfp_app *app,int port_id) +{ +struct nfp_flower_priv *priv = app->priv; +struct net_device *netdev; + +rcu_read_lock (); + netdev =idr_find (&priv->internal_ports.port_ids, port_id); +rcu_read_unlock (); + +return netdev; +} +static void nfp_flower_free_internal_port_id (struct nfp_app *app,struct net_device *netdev) {
@@ -216,12 +229,21 @@ nfp_flower_repr_get_type_and_port(struct nfp_app *app, u32 port_id, u8 *port) }static struct net_device * -nfp_flower_repr_get (struct nfp_app *app,u32 port_id,bool *redir_egress) +nfp_flower_dev_get (struct nfp_app *app,u32 port_id,bool *redir_egress) {enum nfp_repr_type repr_type;struct nfp_reprs *reprs;u8 port =0 ; +/* Check if the port is internal. */ +if (FIELD_GET (NFP_FLOWER_CMSG_PORT_TYPE , port_id) == +NFP_FLOWER_CMSG_PORT_TYPE_OTHER_PORT ) { +if (redir_egress) + *redir_egress = true; + port =FIELD_GET (NFP_FLOWER_CMSG_PORT_PHYS_PORT_NUM , port_id); +return nfp_flower_get_netdev_from_internal_port_id (app, port); + } + repr_type =nfp_flower_repr_get_type_and_port (app, port_id, &port);if (repr_type >NFP_REPR_TYPE_MAX )return NULL ;
@@ -923,7 +945,7 @@ const struct nfp_app_type app_flower = { .sriov_disable = nfp_flower_sriov_disable, .eswitch_mode_get = eswitch_mode_get, - .dev_get = nfp_flower_repr_get, + .dev_get = nfp_flower_dev_get, .setup_tc = nfp_flower_setup_tc, };
Signature · 1 line
2.11.0
PATCH 3/11 nfp: allow fallback packets from non-reprs
In reply to Simon HormanFrom: John Hurley <[email protected]>
Currently, it is assumed that fallback packets will be from reprs. Modify this to allow an app to receive non-repr ports from the fallback channel - e.g. from an internal port. If such a packet is received, do not update repr stats.
Change the naming function calls so as not to imply it will always be a repr netdev returned. Add the option to set a bool value to redirect a fallback packet out the returned port rather than RXing it. Setting of this bool in subsequent patches allows the handling of packets falling back when they are due to egress an internal port.
--- drivers/net/ethernet/netronome/nfp/abm/main.c | 5 +++-- drivers/net/ethernet/netronome/nfp/flower/cmsg.c | 4 ++-- drivers/net/ethernet/netronome/nfp/flower/main.c | 4 ++-- drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c | 4 ++-- drivers/net/ethernet/netronome/nfp/nfp_app.h | 13 ++++++++----- drivers/net/ethernet/netronome/nfp/nfp_net_common.c | 16 +++++++++++++--- 6 files changed, 30 insertions(+), 16 deletions(-)
drivers/net/ethernet/netronome/nfp/abm/main.c +3 -2
@@ -53,7 +53,8 @@ nfp_abm_setup_tc(struct nfp_app *app, struct net_device *netdev, } } -static struct net_device *nfp_abm_repr_get (struct nfp_app *app,u32 port_id) +static struct net_device * +nfp_abm_repr_get (struct nfp_app *app,u32 port_id,bool *redir_egress) {enum nfp_repr_type rtype;struct nfp_reprs *reprs;
@@ -549,5 +550,5 @@ const struct nfp_app_type app_abm = { .eswitch_mode_get = nfp_abm_eswitch_mode_get, .eswitch_mode_set = nfp_abm_eswitch_mode_set, - .repr_get = nfp_abm_repr_get, + .dev_get = nfp_abm_repr_get, };
drivers/net/ethernet/netronome/nfp/flower/cmsg.c +2 -2
@@ -159,7 +159,7 @@ nfp_flower_cmsg_portmod_rx(struct nfp_app *app, struct sk_buff *skb)rtnl_lock ();rcu_read_lock (); - netdev =nfp_app_repr_get (app,be32_to_cpu (msg->portnum)); + netdev =nfp_app_dev_get (app,be32_to_cpu (msg->portnum),NULL );rcu_read_unlock ();if (!netdev) { nfp_flower_cmsg_warn(app, "ctrl msg for unknown port 0x%08x\n",
@@ -192,7 +192,7 @@ nfp_flower_cmsg_portreify_rx(struct nfp_app *app, struct sk_buff *skb) msg =nfp_flower_cmsg_get_data (skb);rcu_read_lock (); - exists = !!nfp_app_repr_get (app,be32_to_cpu (msg->portnum)); + exists = !!nfp_app_dev_get (app,be32_to_cpu (msg->portnum),NULL );rcu_read_unlock ();if (!exists) { nfp_flower_cmsg_warn(app, "ctrl msg for unknown port 0x%08x\n",
drivers/net/ethernet/netronome/nfp/flower/main.c +2 -2
@@ -216,7 +216,7 @@ nfp_flower_repr_get_type_and_port(struct nfp_app *app, u32 port_id, u8 *port) }static struct net_device * -nfp_flower_repr_get (struct nfp_app *app,u32 port_id) +nfp_flower_repr_get (struct nfp_app *app,u32 port_id,bool *redir_egress) {enum nfp_repr_type repr_type;struct nfp_reprs *reprs;
@@ -923,7 +923,7 @@ const struct nfp_app_type app_flower = { .sriov_disable = nfp_flower_sriov_disable, .eswitch_mode_get = eswitch_mode_get, - .repr_get = nfp_flower_repr_get, + .dev_get = nfp_flower_repr_get, .setup_tc = nfp_flower_setup_tc, };
drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c +2 -2
@@ -171,7 +171,7 @@ void nfp_tunnel_keep_alive(struct nfp_app *app, struct sk_buff *skb)for (i =0 ; i < count; i++) { ipv4_addr = payload->tun_info[i].ipv4; port =be32_to_cpu (payload->tun_info[i].egress_port); - netdev =nfp_app_repr_get (app, port); + netdev =nfp_app_dev_get (app, port,NULL );if (!netdev)continue ;
@@ -366,7 +366,7 @@ void nfp_tunnel_request_route(struct nfp_app *app, struct sk_buff *skb) payload =nfp_flower_cmsg_get_data (skb); - netdev =nfp_app_repr_get (app,be32_to_cpu (payload->ingress_port)); + netdev =nfp_app_dev_get (app,be32_to_cpu (payload->ingress_port),NULL );if (!netdev) goto route_fail_warning;
drivers/net/ethernet/netronome/nfp/nfp_app.h +8 -5
@@ -79,7 +79,7 @@ extern const struct nfp_app_type app_abm;* @eswitch_mode_set: set SR-IOV eswitch mode (under pf->lock) * @sriov_enable: app-specific sriov initialisation * @sriov_disable: app-specific sriov clean-up -* @repr_get: get representor netdev +* @dev_get: get representor or internal port representing netdev */ struct nfp_app_type {enum nfp_app_id id;
@@ -143,7 +143,8 @@ struct nfp_app_type {enum devlink_eswitch_mode (*eswitch_mode_get)(struct nfp_app *app);int (*eswitch_mode_set)(struct nfp_app *app,u16 mode); -struct net_device *(*repr_get)(struct nfp_app *app,u32 id); +struct net_device *(*dev_get)(struct nfp_app *app,u32 id, +bool *redir_egress); };/**
@@ -397,12 +398,14 @@ static inline void nfp_app_sriov_disable(struct nfp_app *app) app->type->sriov_disable (app); } -static inline struct net_device *nfp_app_repr_get (struct nfp_app *app,u32 id) +static inline +struct net_device *nfp_app_dev_get (struct nfp_app *app,u32 id, +bool *redir_egress) { -if (unlikely (!app || !app->type->repr_get)) +if (unlikely (!app || !app->type->dev_get))return NULL ; -return app->type->repr_get (app, id); +return app->type->dev_get (app, id, redir_egress); }struct nfp_app *nfp_app_from_netdev (struct net_device *netdev);
drivers/net/ethernet/netronome/nfp/nfp_net_common.c +13 -3
@@ -1683,6 +1683,7 @@ static int nfp_net_rx(struct nfp_net_rx_ring *rx_ring, int budget)struct nfp_net_rx_buf *rxbuf;struct nfp_net_rx_desc *rxd;struct nfp_meta_parsed meta; +bool redir_egress = false;struct net_device *netdev;dma_addr_t new_dma_addr;u32 meta_len_xdp =0 ;
@@ -1818,13 +1819,16 @@ static int nfp_net_rx(struct nfp_net_rx_ring *rx_ring, int budget)struct nfp_net *nn; nn =netdev_priv (dp->netdev); - netdev =nfp_app_repr_get (nn->app, meta.portid); + netdev =nfp_app_dev_get (nn->app, meta.portid, + &redir_egress);if (unlikely (!netdev)) {nfp_net_rx_drop (dp, r_vec, rx_ring, rxbuf,NULL );continue ; } -nfp_repr_inc_rx_stats (netdev, pkt_len); + +if (nfp_netdev_is_nfp_repr (netdev)) +nfp_repr_inc_rx_stats (netdev, pkt_len); } skb =build_skb (rxbuf->frag, true_bufsz);
@@ -1859,7 +1863,13 @@ static int nfp_net_rx(struct nfp_net_rx_ring *rx_ring, int budget)if (meta_len_xdp)skb_metadata_set (skb, meta_len_xdp); -napi_gro_receive (&rx_ring->r_vec->napi, skb); +if (likely (!redir_egress)) { +napi_gro_receive (&rx_ring->r_vec->napi, skb); + }else { + skb->dev = netdev; +__skb_push (skb,ETH_HLEN ); +dev_queue_xmit (skb); + } }if (xdp_prog) {
Signature · 1 line
2.11.0
PATCH 7/11 nfp: flower: handle merge hint messages
In reply to Simon HormanFrom: John Hurley <[email protected]>
If a merge hint is received containing 2 flows that are matched via an implicit recirculation (sending to and matching on an internal port), fw reports that the flows (called sub_flows) may be able to be combined to a single flow.
Add infastructure to accept and process merge hint messages. The actual merging of the flows is left as a stub call.
--- drivers/net/ethernet/netronome/nfp/flower/cmsg.c | 48 +++++++++++++++++++++- drivers/net/ethernet/netronome/nfp/flower/cmsg.h | 10 +++++ drivers/net/ethernet/netronome/nfp/flower/main.h | 3 ++ .../net/ethernet/netronome/nfp/flower/offload.c | 18 ++++++++ 4 files changed, 78 insertions(+), 1 deletion(-)
drivers/net/ethernet/netronome/nfp/flower/cmsg.c +47 -1
@@ -205,6 +205,50 @@ nfp_flower_cmsg_portreify_rx(struct nfp_app *app, struct sk_buff *skb) }static void +nfp_flower_cmsg_merge_hint_rx (struct nfp_app *app,struct sk_buff *skb) +{ +unsigned int msg_len =nfp_flower_cmsg_get_data_len (skb); +struct nfp_flower_cmsg_merge_hint *msg; +struct nfp_fl_payload *sub_flows[2 ]; +int err, i, flow_cnt; + + msg =nfp_flower_cmsg_get_data (skb); +/* msg->count starts at 0 and always assumes at least 1 entry. */ + flow_cnt = msg->count +1 ; + +if (msg_len <struct_size (msg, flow, flow_cnt)) { +nfp_flower_cmsg_warn (app,"Merge hint ctrl msg too short - %d bytes but expect %ld\n" , + msg_len,struct_size (msg, flow, flow_cnt)); +return ; + } + +if (flow_cnt !=2 ) { +nfp_flower_cmsg_warn (app,"Merge hint contains %d flows - two are expected\n" , + flow_cnt); +return ; + } + +rtnl_lock (); +for (i =0 ; i < flow_cnt; i++) { +u32 ctx =be32_to_cpu (msg->flow[i].host_ctx); + + sub_flows[i] =nfp_flower_get_fl_payload_from_ctx (app, ctx); +if (!sub_flows[i]) { +nfp_flower_cmsg_warn (app,"Invalid flow in merge hint\n" ); + goto err_rtnl_unlock; + } + } + + err =nfp_flower_merge_offloaded_flows (app, sub_flows[0 ], sub_flows[1 ]); +/* Only warn on memory fail. Hint veto will not break functionality. */ +if (err == -ENOMEM ) +nfp_flower_cmsg_warn (app,"Flow merge memory fail.\n" ); + +err_rtnl_unlock: +rtnl_unlock (); +} + +static void nfp_flower_cmsg_process_one_rx (struct nfp_app *app,struct sk_buff *skb) {struct nfp_flower_priv *app_priv = app->priv;
@@ -223,8 +267,10 @@ nfp_flower_cmsg_process_one_rx(struct nfp_app *app, struct sk_buff *skb)nfp_flower_cmsg_portmod_rx (app, skb);break ;case NFP_FLOWER_CMSG_TYPE_MERGE_HINT : -if (app_priv->flower_ext_feats &NFP_FL_FEATS_FLOW_MERGE ) +if (app_priv->flower_ext_feats &NFP_FL_FEATS_FLOW_MERGE ) { +nfp_flower_cmsg_merge_hint_rx (app, skb);break ; + } goto err_default;case NFP_FLOWER_CMSG_TYPE_NO_NEIGH :nfp_tunnel_request_route (app, skb);
drivers/net/ethernet/netronome/nfp/flower/cmsg.h +10 -0
@@ -452,6 +452,16 @@ struct nfp_flower_cmsg_portreify {#define NFP_FLOWER_CMSG_PORTREIFY_INFO_EXIST BIT(0) +/* NFP_FLOWER_CMSG_TYPE_FLOW_MERGE_HINT */ +struct nfp_flower_cmsg_merge_hint { +u8 reserved[3 ]; +u8 count; +struct { +__be32 host_ctx; +__be64 host_cookie; + } __packed flow[0]; +}; +enum nfp_flower_cmsg_port_type {NFP_FLOWER_CMSG_PORT_TYPE_UNSPEC =0x0 ,NFP_FLOWER_CMSG_PORT_TYPE_PHYS_PORT =0x1 ,
drivers/net/ethernet/netronome/nfp/flower/main.h +3 -0
@@ -285,6 +285,9 @@ void nfp_flower_metadata_cleanup(struct nfp_app *app);int nfp_flower_setup_tc (struct nfp_app *app,struct net_device *netdev,enum tc_setup_type type,void *type_data); +int nfp_flower_merge_offloaded_flows (struct nfp_app *app, +struct nfp_fl_payload *sub_flow1, +struct nfp_fl_payload *sub_flow2); int nfp_flower_compile_flow_match(struct nfp_app *app, struct tc_cls_flower_offload *flow, struct nfp_fl_key_ls *key_ls,
drivers/net/ethernet/netronome/nfp/flower/offload.c +18 -0
@@ -389,6 +389,24 @@ nfp_flower_allocate_new(struct nfp_fl_key_ls *key_layer) }/** +* nfp_flower_merge_offloaded_flows() - Merge 2 existing flows to single flow. +* @app: Pointer to the APP handle +* @sub_flow1: Initial flow matched to produce merge hint +* @sub_flow2: Post recirculation flow matched in merge hint +* +* Combines 2 flows (if valid) to a single flow, removing the initial from hw +* and offloading the new, merged flow. +* +* Return: negative value on error, 0 in success. +*/ +int nfp_flower_merge_offloaded_flows (struct nfp_app *app, +struct nfp_fl_payload *sub_flow1, +struct nfp_fl_payload *sub_flow2) +{ +return -EOPNOTSUPP ; +} + +/** * nfp_flower_add_offload() - Adds a new flow to hardware. * @app: Pointer to the APP handle * @netdev: netdev structure.
Signature · 1 line
2.11.0
PATCH 8/11 nfp: flower: validate merge hint flows
In reply to Simon HormanFrom: John Hurley <[email protected]>
Two flows can be merged if the second flow (after recirculation) matches on bits that are either matched on or explicitly set by the first flow. This means that if a packet hits flow 1 and recirculates then it is guaranteed to hit flow 2.
Add a 'can_merge' function that determines if 2 sub_flows in a merge hint can be validly merged to a single flow.
--- .../net/ethernet/netronome/nfp/flower/offload.c | 228 +++++++++++++++++++++ 1 file changed, 228 insertions(+)
drivers/net/ethernet/netronome/nfp/flower/offload.c +228 -0
@@ -55,6 +55,28 @@ BIT(FLOW_DISSECTOR_KEY_ENC_IPV4_ADDRS) | \ BIT(FLOW_DISSECTOR_KEY_ENC_PORTS)) +#define NFP_FLOWER_MERGE_FIELDS \ + (NFP_FLOWER_LAYER_PORT | \ + NFP_FLOWER_LAYER_MAC | \ + NFP_FLOWER_LAYER_TP | \ + NFP_FLOWER_LAYER_IPV4 | \ + NFP_FLOWER_LAYER_IPV6) + +struct nfp_flower_merge_check { +union { +struct { +__be16 tci; +struct nfp_flower_mac_mpls l2; +struct nfp_flower_tp_ports l4; +union { +struct nfp_flower_ipv4 ipv4; +struct nfp_flower_ipv6 ipv6; + }; + }; +unsigned long vals[8 ]; + }; +}; +static int nfp_flower_xmit_flow (struct nfp_app *app,struct nfp_fl_payload *nfp_flow,u8 mtype)
@@ -388,6 +410,206 @@ nfp_flower_allocate_new(struct nfp_fl_key_ls *key_layer)return NULL ; } +static int +nfp_flower_update_merge_with_actions (struct nfp_fl_payload *flow, +struct nfp_flower_merge_check *merge, +u8 *last_act_id,int *act_out) +{ +struct nfp_fl_set_ipv6_tc_hl_fl *ipv6_tc_hl_fl; +struct nfp_fl_set_ip4_ttl_tos *ipv4_ttl_tos; +struct nfp_fl_set_ip4_addrs *ipv4_add; +struct nfp_fl_set_ipv6_addr *ipv6_add; +struct nfp_fl_push_vlan *push_vlan; +struct nfp_fl_set_tport *tport; +struct nfp_fl_set_eth *eth; +struct nfp_fl_act_head *a; +unsigned int act_off =0 ; +u8 act_id =0 ; +u8 *ports; +int i; + +while (act_off < flow->meta.act_len) { + a = (struct nfp_fl_act_head *)&flow->action_data[act_off]; + act_id = a->jump_id; + +switch (act_id) { +case NFP_FL_ACTION_OPCODE_OUTPUT : +if (act_out) + (*act_out)++; +break ; +case NFP_FL_ACTION_OPCODE_PUSH_VLAN : + push_vlan = (struct nfp_fl_push_vlan *)a; +if (push_vlan->vlan_tci) + merge->tci =cpu_to_be16 (0xffff ); +break ; +case NFP_FL_ACTION_OPCODE_POP_VLAN : + merge->tci =cpu_to_be16 (0 ); +break ; +case NFP_FL_ACTION_OPCODE_SET_IPV4_TUNNEL : +/* New tunnel header means l2 to l4 can be matched. */ +eth_broadcast_addr (&merge->l2.mac_dst[0 ]); +eth_broadcast_addr (&merge->l2.mac_src[0 ]); +memset (&merge->l4,0xff , +sizeof (struct nfp_flower_tp_ports )); +memset (&merge->ipv4,0xff , +sizeof (struct nfp_flower_ipv4 )); +break ; +case NFP_FL_ACTION_OPCODE_SET_ETHERNET : + eth = (struct nfp_fl_set_eth *)a; +for (i =0 ; i <ETH_ALEN ; i++) + merge->l2.mac_dst[i] |= eth->eth_addr_mask[i]; +for (i =0 ; i <ETH_ALEN ; i++) + merge->l2.mac_src[i] |= + eth->eth_addr_mask[ETH_ALEN + i]; +break ; +case NFP_FL_ACTION_OPCODE_SET_IPV4_ADDRS : + ipv4_add = (struct nfp_fl_set_ip4_addrs *)a; + merge->ipv4.ipv4_src |= ipv4_add->ipv4_src_mask; + merge->ipv4.ipv4_dst |= ipv4_add->ipv4_dst_mask; +break ; +case NFP_FL_ACTION_OPCODE_SET_IPV4_TTL_TOS : + ipv4_ttl_tos = (struct nfp_fl_set_ip4_ttl_tos *)a; + merge->ipv4.ip_ext.ttl |= ipv4_ttl_tos->ipv4_ttl_mask; + merge->ipv4.ip_ext.tos |= ipv4_ttl_tos->ipv4_tos_mask; +break ; +case NFP_FL_ACTION_OPCODE_SET_IPV6_SRC : + ipv6_add = (struct nfp_fl_set_ipv6_addr *)a; +for (i =0 ; i <4 ; i++) + merge->ipv6.ipv6_src.in6_u.u6_addr32[i] |= + ipv6_add->ipv6[i].mask; +break ; +case NFP_FL_ACTION_OPCODE_SET_IPV6_DST : + ipv6_add = (struct nfp_fl_set_ipv6_addr *)a; +for (i =0 ; i <4 ; i++) + merge->ipv6.ipv6_dst.in6_u.u6_addr32[i] |= + ipv6_add->ipv6[i].mask; +break ; +case NFP_FL_ACTION_OPCODE_SET_IPV6_TC_HL_FL : + ipv6_tc_hl_fl = (struct nfp_fl_set_ipv6_tc_hl_fl *)a; + merge->ipv6.ip_ext.ttl |= + ipv6_tc_hl_fl->ipv6_hop_limit_mask; + merge->ipv6.ip_ext.tos |= ipv6_tc_hl_fl->ipv6_tc_mask; + merge->ipv6.ipv6_flow_label_exthdr |= + ipv6_tc_hl_fl->ipv6_label_mask; +break ; +case NFP_FL_ACTION_OPCODE_SET_UDP : +case NFP_FL_ACTION_OPCODE_SET_TCP : + tport = (struct nfp_fl_set_tport *)a; + ports = (u8 *)&merge->l4.port_src; +for (i =0 ; i <4 ; i++) + ports[i] |= tport->tp_port_mask[i]; +break ; +case NFP_FL_ACTION_OPCODE_PRE_TUNNEL : +case NFP_FL_ACTION_OPCODE_PRE_LAG : +case NFP_FL_ACTION_OPCODE_PUSH_GENEVE : +break ; +default : +return -EOPNOTSUPP ; + } + + act_off += a->len_lw <<NFP_FL_LW_SIZ ; + } + +if (last_act_id) + *last_act_id = act_id; + +return 0 ; +} + +static int +nfp_flower_populate_merge_match (struct nfp_fl_payload *flow, +struct nfp_flower_merge_check *merge, +bool extra_fields) +{ +struct nfp_flower_meta_tci *meta_tci; +u8 *mask = flow->mask_data; +u8 key_layer, match_size; + +memset (merge,0 ,sizeof (struct nfp_flower_merge_check )); + + meta_tci = (struct nfp_flower_meta_tci *)mask; + key_layer = meta_tci->nfp_flow_key_layer; + +if (key_layer & ~NFP_FLOWER_MERGE_FIELDS && !extra_fields) +return -EOPNOTSUPP ; + + merge->tci = meta_tci->tci; + mask +=sizeof (struct nfp_flower_meta_tci ); + +if (key_layer &NFP_FLOWER_LAYER_EXT_META ) + mask +=sizeof (struct nfp_flower_ext_meta ); + + mask +=sizeof (struct nfp_flower_in_port ); + +if (key_layer &NFP_FLOWER_LAYER_MAC ) { + match_size =sizeof (struct nfp_flower_mac_mpls ); +memcpy (&merge->l2, mask, match_size); + mask += match_size; + } + +if (key_layer &NFP_FLOWER_LAYER_TP ) { + match_size =sizeof (struct nfp_flower_tp_ports ); +memcpy (&merge->l4, mask, match_size); + mask += match_size; + } + +if (key_layer &NFP_FLOWER_LAYER_IPV4 ) { + match_size =sizeof (struct nfp_flower_ipv4 ); +memcpy (&merge->ipv4, mask, match_size); + } + +if (key_layer &NFP_FLOWER_LAYER_IPV6 ) { + match_size =sizeof (struct nfp_flower_ipv6 ); +memcpy (&merge->ipv6, mask, match_size); + } + +return 0 ; +} + +static int +nfp_flower_can_merge (struct nfp_fl_payload *sub_flow1, +struct nfp_fl_payload *sub_flow2) +{ +/* Two flows can be merged if sub_flow2 only matches on bits that are +* either matched by sub_flow1 or set by a sub_flow1 action. This +* ensures that every packet that hits sub_flow1 and recirculates is +* guaranteed to hit sub_flow2. +*/ +struct nfp_flower_merge_check sub_flow1_merge, sub_flow2_merge; +int err, act_out =0 ; +u8 last_act_id =0 ; + + err =nfp_flower_populate_merge_match (sub_flow1, &sub_flow1_merge, + true); +if (err) +return err; + + err =nfp_flower_populate_merge_match (sub_flow2, &sub_flow2_merge, + false); +if (err) +return err; + + err =nfp_flower_update_merge_with_actions (sub_flow1, &sub_flow1_merge, + &last_act_id, &act_out); +if (err) +return err; + +/* Must only be 1 output action and it must be the last in sequence. */ +if (act_out !=1 || last_act_id !=NFP_FL_ACTION_OPCODE_OUTPUT ) +return -EOPNOTSUPP ; + +/* Reject merge if sub_flow2 matches on something that is not matched +* on or set in an action by sub_flow1. +*/ + err =bitmap_andnot (sub_flow2_merge.vals, sub_flow2_merge.vals, + sub_flow1_merge.vals, +sizeof (struct nfp_flower_merge_check ) *8 ); +if (err) +return -EINVAL ; + +return 0 ; +} +/** * nfp_flower_merge_offloaded_flows() - Merge 2 existing flows to single flow. * @app: Pointer to the APP handle
@@ -403,6 +625,12 @@ int nfp_flower_merge_offloaded_flows(struct nfp_app *app,struct nfp_fl_payload *sub_flow1, struct nfp_fl_payload *sub_flow2) { + int err; + + err =nfp_flower_can_merge (sub_flow1, sub_flow2); +if (err) +return err; +return -EOPNOTSUPP ; }
Signature · 1 line
2.11.0
PATCH 9/11 nfp: flower: generate merge flow rule
In reply to Simon HormanFrom: John Hurley <[email protected]>
When combining 2 sub_flows to a single 'merge flow' (assuming the merge is valid), the merge flow should contain the same match fields as sub_flow 1 with actions derived from a combination of sub_flows 1 and 2. This action list should have all actions from sub_flow 1 with the exception of the output action that triggered the 'implicit recirculation' by sending to an internal port, followed by all actions of sub_flow 2. Any pre-actions in either sub_flow should feature at the start of the action list.
Add code to generate a new merge flow and populate the match and actions fields based on the sub_flows. The offloading of the flow is left to future patches.
--- drivers/net/ethernet/netronome/nfp/flower/main.h | 9 ++ .../net/ethernet/netronome/nfp/flower/offload.c | 142 ++++++++++++++++++++- 2 files changed, 150 insertions(+), 1 deletion(-)
drivers/net/ethernet/netronome/nfp/flower/main.h +9 -0
@@ -279,6 +279,15 @@ nfp_flower_internal_port_can_offload(struct nfp_app *app,return false; } +/* The address of the merged flow acts as its cookie. +* Cookies supplied to us by TC flower are also addresses to allocated +* memory and thus this scheme should not generate any collisions. +*/ +static inline bool nfp_flower_is_merge_flow (struct nfp_fl_payload *flow_pay) +{ +return flow_pay->tc_flower_cookie == (unsigned long )flow_pay; +} +int nfp_flower_metadata_init (struct nfp_app *app,u64 host_ctx_count,unsigned int host_ctx_split);void nfp_flower_metadata_cleanup (struct nfp_app *app);
drivers/net/ethernet/netronome/nfp/flower/offload.c +141 -1
160 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH 10/11 nfp: flower: support stats update for merge flows
In reply to Simon HormanFrom: John Hurley <[email protected]>
With the merging of 2 sub flows, a new 'merge' flow will be created and written to FW. The TC layer is unaware that the merge flow exists and will request stats from the sub flows. Conversely, the FW treats a merge rule the same as any other rule and sends stats updates to the NFP driver.
Add links between merge flows and their sub flows. Use these links to pass merge flow stats updates from FW to the underlying sub flows, ensuring TC stats requests are handled correctly. The updating of sub flow stats is done on (the less time critcal) TC stats requests rather than on FW stats update.
--- drivers/net/ethernet/netronome/nfp/flower/main.h | 18 ++++ .../net/ethernet/netronome/nfp/flower/offload.c | 99 ++++++++++++++++++++++ 2 files changed, 117 insertions(+)
drivers/net/ethernet/netronome/nfp/flower/main.h +18 -0
@@ -252,6 +252,24 @@ struct nfp_fl_payload {char *unmasked_data;char *mask_data;char *action_data; +struct list_head linked_flows; +}; + +struct nfp_fl_payload_link { +/* A link contains a pointer to a merge flow and an associated sub_flow. +* Each merge flow will feature in 2 links to its underlying sub_flows. +* A sub_flow will have at least 1 link to a merge flow or more if it +* has been used to create multiple merge flows. +* +* For a merge flow, 'linked_flows' in its nfp_fl_payload struct lists +* all links to sub_flows (sub_flow.flow) via merge.list. +* For a sub_flow, 'linked_flows' gives all links to merge flows it has +* formed (merge_flow.flow) via sub_flow.list. +*/ +struct { +struct list_head list; +struct nfp_fl_payload *flow; + } merge_flow, sub_flow; };extern const struct rhashtable_params nfp_flower_table_params;
drivers/net/ethernet/netronome/nfp/flower/offload.c +99 -0
131 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH 11/11 nfp: flower: offload merge flows
In reply to Simon HormanFrom: John Hurley <[email protected]>
A merge flow is formed from 2 sub flows. The match fields of the merge are the same as the first sub flow that has formed it, with the actions being a combination of the first and second sub flow. Therefore, a merge flow should replace sub flow 1 when offloaded.
Offload valid merge flows by using a new 'flow mod' message type to replace an existing offloaded rule. Track the deletion of sub flows that are linked to a merge flow and revert offloaded merge rules if required.
--- drivers/net/ethernet/netronome/nfp/flower/cmsg.h | 1 + drivers/net/ethernet/netronome/nfp/flower/main.h | 3 + .../net/ethernet/netronome/nfp/flower/metadata.c | 16 +-- .../net/ethernet/netronome/nfp/flower/offload.c | 119 +++++++++++++++++++-- 4 files changed, 126 insertions(+), 13 deletions(-)
drivers/net/ethernet/netronome/nfp/flower/cmsg.h +1 -0
@@ -402,6 +402,7 @@ struct nfp_flower_cmsg_hdr {/* Types defined for port related control messages */ enum nfp_flower_cmsg_type_port {NFP_FLOWER_CMSG_TYPE_FLOW_ADD =0 , +NFP_FLOWER_CMSG_TYPE_FLOW_MOD =1 ,NFP_FLOWER_CMSG_TYPE_FLOW_DEL =2 ,NFP_FLOWER_CMSG_TYPE_LAG_CONFIG =4 ,NFP_FLOWER_CMSG_TYPE_PORT_REIFY =6 ,
drivers/net/ethernet/netronome/nfp/flower/main.h +3 -0
@@ -253,6 +253,7 @@ struct nfp_fl_payload {char *mask_data;char *action_data;struct list_head linked_flows; +bool in_hw; };struct nfp_fl_payload_link {
@@ -329,6 +330,8 @@ int nfp_compile_flow_metadata(struct nfp_app *app,struct tc_cls_flower_offload *flow, struct nfp_fl_payload *nfp_flow, struct net_device *netdev); +void __nfp_modify_flow_metadata (struct nfp_flower_priv *priv, +struct nfp_fl_payload *nfp_flow);int nfp_modify_flow_metadata (struct nfp_app *app,struct nfp_fl_payload *nfp_flow);
drivers/net/ethernet/netronome/nfp/flower/metadata.c +10 -6
@@ -276,9 +276,6 @@ nfp_check_mask_remove(struct nfp_app *app, char *mask_data, u32 mask_len,if (!mask_entry)return false; -if (meta_flags) - *meta_flags &= ~NFP_FL_META_FLAG_MANAGE_MASK ; - *mask_id = mask_entry->mask_id; mask_entry->ref_cnt--;if (!mask_entry->ref_cnt) {
@@ -367,6 +364,14 @@ int nfp_compile_flow_metadata(struct nfp_app *app,return err; } +void __nfp_modify_flow_metadata (struct nfp_flower_priv *priv, +struct nfp_fl_payload *nfp_flow) +{ + nfp_flow->meta.flags &= ~NFP_FL_META_FLAG_MANAGE_MASK ; + nfp_flow->meta.flow_version =cpu_to_be64 (priv->flower_version); + priv->flower_version++; +} +int nfp_modify_flow_metadata (struct nfp_app *app,struct nfp_fl_payload *nfp_flow) {
@@ -375,13 +380,12 @@ int nfp_modify_flow_metadata(struct nfp_app *app,u8 new_mask_id =0 ;u32 temp_ctx_id; +__nfp_modify_flow_metadata (priv, nfp_flow); +nfp_check_mask_remove (app, nfp_flow->mask_data, nfp_flow->meta.mask_len, &nfp_flow->meta.flags, &new_mask_id); - nfp_flow->meta.flow_version =cpu_to_be64 (priv->flower_version); - priv->flower_version++; -/* Update flow payload with mask ids. */ nfp_flow->unmasked_data[NFP_FL_MASK_ID_LOCATION ] = new_mask_id;
drivers/net/ethernet/netronome/nfp/flower/offload.c +112 -7
175 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH 6/11 nfp: flower: get flows by host context
In reply to Simon HormanFrom: John Hurley <[email protected]>
Each flow is given a context ID that the fw uses (along with its cookie) to identity the flow. The flows stats are updated by the fw via this ID which is a reference to a pre-allocated array entry.
In preparation for flow merge code, enable the nfp_fl_payload structure to be accessed via this stats context ID. Rather than increasing the memory requirements of the pre-allocated array, add a new rhashtable to associate each active stats context ID with its rule payload.
While adding new code to the compile metadata functions, slightly restructure the existing function to allow for cleaner, easier to read error handling.
--- drivers/net/ethernet/netronome/nfp/flower/main.h | 4 + .../net/ethernet/netronome/nfp/flower/metadata.c | 101 +++++++++++++++++---- 2 files changed, 89 insertions(+), 16 deletions(-)
drivers/net/ethernet/netronome/nfp/flower/main.h +4 -0
@@ -140,6 +140,7 @@ struct nfp_fl_internal_ports {* @flow_table: Hash table used to store flower rules * @stats: Stored stats updates for flower rules * @stats_lock: Lock for flower rule stats updates +* @stats_ctx_table: Hash table to map stats contexts to its flow rule * @cmsg_work: Workqueue for control messages processing * @cmsg_skbs_high: List of higher priority skbs for control message * processing
@@ -170,6 +171,7 @@ struct nfp_flower_priv {struct rhashtable flow_table;struct nfp_fl_stats *stats;spinlock_t stats_lock;/* lock stats */ +struct rhashtable stats_ctx_table;struct work_struct cmsg_work;struct sk_buff_head cmsg_skbs_high;struct sk_buff_head cmsg_skbs_low;
@@ -304,6 +306,8 @@ struct nfp_fl_payload * nfp_flower_search_fl_table(struct nfp_app *app, unsigned long tc_flower_cookie, struct net_device *netdev);struct nfp_fl_payload * +nfp_flower_get_fl_payload_from_ctx (struct nfp_app *app,u32 ctx_id); +struct nfp_fl_payload *nfp_flower_remove_fl_table (struct nfp_app *app,unsigned long tc_flower_cookie);void nfp_flower_rx_flow_stats (struct nfp_app *app,struct sk_buff *skb);
drivers/net/ethernet/netronome/nfp/flower/metadata.c +85 -16
176 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH 5/11 nfp: flower: allow tunnels to output to internal port
In reply to Simon HormanFrom: John Hurley <[email protected]>
The neighbour table in the FW only accepts next hop entries if the egress port is an nfp repr. Modify this to allow the next hop to be an internal port. This means that if a packet is to egress to that port, it will recirculate back into the system with the internal port becoming its ingress port.
--- drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c +4 -3
@@ -270,9 +270,10 @@ nfp_tun_write_neigh(struct net_device *netdev, struct nfp_app *app, struct flowi4 *flow, struct neighbour *neigh, gfp_t flag) { struct nfp_tun_neigh payload; +u32 port_id; -/* Only offload representor IPv4s for now. */ -if (!nfp_netdev_is_nfp_repr (netdev)) + port_id =nfp_flower_get_port_id_from_netdev (app, netdev); +if (!port_id)return ;memset (&payload,0 ,sizeof (struct nfp_tun_neigh ));
@@ -290,7 +291,7 @@ nfp_tun_write_neigh(struct net_device *netdev, struct nfp_app *app, payload.src_ipv4 = flow->saddr;ether_addr_copy (payload.src_addr, netdev->dev_addr);neigh_ha_snapshot (payload.dst_addr, neigh, netdev); - payload.port_id =cpu_to_be32 (nfp_repr_get_port_id (netdev)); + payload.port_id =cpu_to_be32 (port_id);/* Add destination of new route to NFP cache. */ nfp_tun_add_route_to_cache (app, payload.dst_ipv4);
Signature · 1 line
2.11.0
David Miller
maintainerFrom: Simon Horman <[email protected]>
Date: Mon, 15 Apr 2019 16:55:52 +0200
Quoted 12 lines
John Hurley says,
These patches deal with 'implicit recirculation' on the NFP. This is a firmware feature whereby a packet egresses to an 'internal' port meaning that it will recirculate back to the header extract phase with the 'internal' port now marked as its ingress port. This internal port can then be matched on by another rule. This process simulates how OvS datapath outputs to an internal port. The FW traces the packet's recirculation route and sends a 'merge hint' to the driver telling it which flows it matched against. The driver can then decide if these flows can be merged to a single rule and offloaded.
Quoted 7 lines
The patches deal with the following issues:
- assigning/freeing IDs to/from each of these new internal ports
- offloading rules that match on internal ports
- offloading neighbour table entries whose egress port is internal
- handling fallback traffic with an internal port as ingress
- using merge hints to create 'faster path' flows and tracking stats etc.
Series applied, thanks Simon.