ice: PPPoE offload support
Subsystems (4)
v5 cover ice: PPPoE offload support
Add support for dissecting PPPoE and PPP-specific fields in flow dissector:
PPPoE session id and PPP protocol type. Add support for those fields in tc-flower and support offloading PPPoE. Finally, add support for hardware offload of PPPoE packets in switchdev mode in ice driver.
Example filter:
tc filter add dev $PF1 ingress protocol ppp_ses prio 1 flower pppoe_sid \
1234 ppp_proto ip skip_sw action mirred egress redirect dev $VF1_PR
Changes in iproute2 are required to use the new fields (will be submitted soon).
ICE COMMS DDP package is required to create a filter in ice.
v5: fix endianness when processing compressed protocols
v4:
* PPPoE header validation
* added MPLS support
* added support for compressed PPP protocol field
* flow_dissector_key_pppoe::session_id stored in __be16
* new field: flow_dissector_key_pppoe::type
* always add an ethtype lookup if PPP/PPPoE options are provided (to prevent setting incorrect ethtype)
* rebase
v3:
* revert byte order changes in is_ppp_proto_supported from previous version
* add kernel-doc for is_ppp_proto_supported
* add more CC
v2: cosmetic changes
Marcin Szycik (1):
ice: Add support for PPPoE hardware offload
Wojciech Drewek (3):
flow_dissector: Add PPPoE dissectors
net/sched: flower: Add PPPoE filter
flow_offload: Introduce flow_match_pppoe
drivers/net/ethernet/intel/ice/ice.h | 1 + .../net/ethernet/intel/ice/ice_flex_pipe.c | 5 +- .../ethernet/intel/ice/ice_protocol_type.h | 11 ++ drivers/net/ethernet/intel/ice/ice_switch.c | 165 ++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_tc_lib.c | 71 +++++++- drivers/net/ethernet/intel/ice/ice_tc_lib.h | 8 + include/net/flow_dissector.h | 13 ++ include/net/flow_offload.h | 6 + include/uapi/linux/pkt_cls.h | 3 + net/core/flow_dissector.c | 85 ++++++++- net/core/flow_offload.c | 7 + net/sched/cls_flower.c | 61 +++++++ 12 files changed, 427 insertions(+), 9 deletions(-)
Signature · 1 line
2.35.1
RFC PATCH v5 1/4 flow_dissector: Add PPPoE dissectors
From: Wojciech Drewek <[email protected]>
Allow to dissect PPPoE specific fields which are:
- session ID (16 bits)
- ppp protocol (16 bits)
- type (16 bits) - this is PPPoE ethertype, for now only ETH_P_PPP_SES is supported, possible ETH_P_PPP_DISC in the future
The goal is to make the following TC command possible:
# tc filter add dev ens6f0 ingress prio 1 protocol ppp_ses \
flower \
pppoe_sid 12 \
ppp_proto ip \
action dropNote that only PPPoE Session is supported.
---
v5: fix endianness when processing compressed protocols v4:
* pppoe header validation
* added MPLS dissection
* added support for compressed ppp protocol field
* flow_dissector_key_pppoe::session_id stored in __be16
* new field: flow_dissector_key_pppoe::type
v3: revert byte order changes in is_ppp_proto_supported from
previous version
v2: ntohs instead of htons in is_ppp_proto_supported
include/net/flow_dissector.h | 13 ++++++ net/core/flow_dissector.c | 85 +++++++++++++++++++++++++++++++++--- 2 files changed, 91 insertions(+), 7 deletions(-)
include/net/flow_dissector.h +13 -0
@@ -277,6 +277,18 @@ struct flow_dissector_key_num_of_vlans {u8 num_of_vlans; }; +/** +* struct flow_dissector_key_pppoe: +* @session_id: pppoe session id +* @ppp_proto: ppp protocol +* @type: pppoe eth type +*/ +struct flow_dissector_key_pppoe { +__be16 session_id; +__be16 ppp_proto; +__be16 type; +}; +enum flow_dissector_key_id {FLOW_DISSECTOR_KEY_CONTROL ,/* struct flow_dissector_key_control */ FLOW_DISSECTOR_KEY_BASIC ,/* struct flow_dissector_key_basic */
@@ -307,6 +319,7 @@ enum flow_dissector_key_id {FLOW_DISSECTOR_KEY_CT ,/* struct flow_dissector_key_ct */ FLOW_DISSECTOR_KEY_HASH ,/* struct flow_dissector_key_hash */ FLOW_DISSECTOR_KEY_NUM_OF_VLANS ,/* struct flow_dissector_key_num_of_vlans */ +FLOW_DISSECTOR_KEY_PPPOE ,/* struct flow_dissector_key_pppoe */ FLOW_DISSECTOR_KEY_MAX, };
net/core/flow_dissector.c +78 -7
110 lines not on this page · raw message
Signature · 1 line
2.35.1
Re: [RFC PATCH net-next v5 1/4] flow_dissector: Add PPPoE dissectors
Quoted 20 lines · Marcin Szycik
net/core/flow_dissector.c +20
-0+/** +* is_ppp_proto_supported - checks if inner PPP protocol should be dissected +* @proto: protocol type (PPP proto field) +*/ +static bool is_ppp_proto_supported (__be16 proto) +{ +switch (proto) { +case htons (PPP_AT ): +case htons (PPP_IPX ): +case htons (PPP_VJC_COMP ): +case htons (PPP_VJC_UNCOMP ): +case htons (PPP_MP ): +case htons (PPP_COMPFRAG ): +case htons (PPP_COMP ): +case htons (PPP_IPCP ): +case htons (PPP_ATCP ): +case htons (PPP_IPXCP ): +case htons (PPP_IPV6CP ): +case htons (PPP_CCPFRAG ): +case htons (PPP_MPLSCP ):
net/core/flow_dissector.c bool bpf_flow_dissect(struct bpf_prog *prog, struct bpf_flow_dissector *ctx, · line 927
Quoted 10 lines
net/core/flow_dissector.c +10
-0+case htons (PPP_LCP ): +case htons (PPP_PAP ): +case htons (PPP_LQR ): +case htons (PPP_CHAP ): +case htons (PPP_CBCP ): +return true; +default : +return false; + } +}
The more I think about it, the more I believe we should make this function more generic by following the Protocol field definition found in section 2 of RFC 1661:
https://datatracker.ietf.org/doc/html/rfc1661#section-2
I mean, it's very surprising that is_ppp_proto_supported() returns false for protocols like PPP_IP or PPP_IPV6, which certainly are supported. Of course, in the context of your patch, PPP_IP and PPP_IPV6 have been tested first, but that makes the code a bit unclear.
We could define a simpler and more generic helper function (probably in a ppp header file). Something like (unstested):
/* Assumes proto isn't compressed. */
static bool ppp_proto_is_valid(u16 proto) /*
{
/* Protocol must be odd and the least significant bit of the
* most significant octet must be 0 (see RFC 1661, section 2).
*/
return !!(proto & 0X0101 == 0x0001)
}BTW, we don't have to restrict the list of supported protocols to the PPP_* numbers defined in the kernel as we have no indication that the PPP frame is going to be handled locally.
Quoted 19 lines
net/core/flow_dissector.c +7
-0+static bool is_pppoe_ses_hdr_valid (struct pppoe_hdr hdr) +{ +return hdr.ver ==1 && hdr.type ==1 && hdr.code ==0 ; +} +/** * __skb_flow_dissect - extract the flow_keys struct and return it * @net: associated network namespace, derived from @skb if NULL @@ -1214,26 +1250,61 @@ bool __skb_flow_dissect(const struct net *net,struct pppoe_hdr hdr;__be16 proto; } *hdr, _hdr; +u16 ppp_proto; + hdr =__skb_header_pointer (skb, nhoff,sizeof (_hdr), data, hlen, &_hdr);if (!hdr) { fdret =FLOW_DISSECT_RET_OUT_BAD ;break ; }
net/core/flow_dissector.c bool __skb_flow_dissect(const struct net *net, · line 1266
Quoted 10 lines
net/core/flow_dissector.c +6
-3- nhoff +=PPPOE_SES_HLEN ; -switch (hdr->proto) { -case htons (PPP_IP ): +if (!is_pppoe_ses_hdr_valid (hdr->hdr)) { + fdret =FLOW_DISSECT_RET_OUT_BAD ; +break ; + } + +/* least significant bit of the least significant octet
That's the least significant bit of the _most significant_ octet (the one of the least significant octet must always be 1).
net/core/flow_dissector.c bool __skb_flow_dissect(const struct net *net, · line 1270
Quoted 4 lines
net/core/flow_dissector.c +4
-0+* indicates if protocol field was compressed +*/ + ppp_proto =ntohs (hdr->proto); +if (ppp_proto &256 ) {
Using hex would improve readability in my opinion (that is, s/256/0x0100/).
net/core/flow_dissector.c bool __skb_flow_dissect(const struct net *net, · line 1271
Quoted 1 line
net/core/flow_dissector.c +1
-0+ ppp_proto =htons (ppp_proto >>8 );
I don't get why you convert ppp_proto back to network byte order. That contradicts the type annotation (u16).
net/core/flow_dissector.c bool __skb_flow_dissect(const struct net *net, · line 1274
Quoted 3 lines
net/core/flow_dissector.c +3
-0+ nhoff +=PPPOE_SES_HLEN -1 ; + }else { + ppp_proto =htons (ppp_proto);
Same here. We could leave ppp_proto untouched in this branch.
net/core/flow_dissector.c bool __skb_flow_dissect(const struct net *net, · line 1278
Quoted 4 lines
net/core/flow_dissector.c +4
-0+ nhoff +=PPPOE_SES_HLEN ; + } + +if (ppp_proto ==htons (PPP_IP )) {
With ppp_proto kept in host byte order, the htons() call would need to go.
net/core/flow_dissector.c bool __skb_flow_dissect(const struct net *net, · line 1281
Quoted 5 lines
net/core/flow_dissector.c +1
-2proto =htons (ETH_P_IP ); fdret =FLOW_DISSECT_RET_PROTO_AGAIN ; -break ; -case htons (PPP_IPV6 ): + }else if (ppp_proto ==htons (PPP_IPV6 )) {
Same here, and in the following 'if' branches.
Quoted 16 lines
net/core/flow_dissector.c +9
-2proto =htons (ETH_P_IPV6 ); fdret =FLOW_DISSECT_RET_PROTO_AGAIN ; -break ; -default : + }else if (ppp_proto ==htons (PPP_MPLS_UC )) { + proto =htons (ETH_P_MPLS_UC ); + fdret =FLOW_DISSECT_RET_PROTO_AGAIN ; + }else if (ppp_proto ==htons (PPP_MPLS_MC )) { + proto =htons (ETH_P_MPLS_MC ); + fdret =FLOW_DISSECT_RET_PROTO_AGAIN ; + }else if (is_ppp_proto_supported (ppp_proto)) { + fdret =FLOW_DISSECT_RET_OUT_GOOD ; + }else { fdret =FLOW_DISSECT_RET_OUT_BAD ;break ; }
net/core/flow_dissector.c bool __skb_flow_dissect(const struct net *net, · line 1305
Quoted 10 lines
net/core/flow_dissector.c +10
-0+ +if (dissector_uses_key (flow_dissector, +FLOW_DISSECTOR_KEY_PPPOE )) { +struct flow_dissector_key_pppoe *key_pppoe; + + key_pppoe =skb_flow_dissector_target (flow_dissector, +FLOW_DISSECTOR_KEY_PPPOE , + target_container); + key_pppoe->session_id = hdr->hdr.sid; + key_pppoe->ppp_proto = ppp_proto;
With ppp_proto being u16, we'd now need to call htons(ppp_proto).
Quoted 8 lines
net/core/flow_dissector.c +2
-0+ key_pppoe->type =htons (ETH_P_PPP_SES ); + }break ; }case htons (ETH_P_TIPC ): {Signature · 1 line
2.35.1
RFC PATCH v5 2/4 net/sched: flower: Add PPPoE filter
In reply to Marcin SzycikFrom: Wojciech Drewek <[email protected]>
Add support for PPPoE specific fields for tc-flower. Those fields can be provided only when protocol was set to ETH_P_PPP_SES. Defines, dump, load and set are being done here.
Overwrite basic.n_proto only in case of PPP_IP and PPP_IPV6, otherwise leave it as ETH_P_PPP_SES.
---
v4:
* support of MPLS inner fields
* session_id stored in __be16
include/uapi/linux/pkt_cls.h | 3 ++ net/sched/cls_flower.c | 61 ++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+)
include/uapi/linux/pkt_cls.h +3 -0
@@ -589,6 +589,9 @@ enum {TCA_FLOWER_KEY_NUM_OF_VLANS ,/* u8 */ +TCA_FLOWER_KEY_PPPOE_SID ,/* be16 */ +TCA_FLOWER_KEY_PPP_PROTO ,/* be16 */ + __TCA_FLOWER_MAX, };
net/sched/cls_flower.c +61 -0
103 lines not on this page · raw message
Signature · 1 line
2.35.1
RFC PATCH v5 3/4 flow_offload: Introduce flow_match_pppoe
In reply to Marcin SzycikFrom: Wojciech Drewek <[email protected]>
Allow to offload PPPoE filters by adding flow_rule_match_pppoe. Drivers can extract PPPoE specific fields from now on.
--- include/net/flow_offload.h | 6 ++++++ net/core/flow_offload.c | 7 +++++++ 2 files changed, 13 insertions(+)
include/net/flow_offload.h +6 -0
@@ -76,6 +76,10 @@ struct flow_match_ct {struct flow_dissector_key_ct *key, *mask; }; +struct flow_match_pppoe { +struct flow_dissector_key_pppoe *key, *mask; +}; +struct flow_rule ; void flow_rule_match_meta(const struct flow_rule *rule,
@@ -122,6 +126,8 @@ void flow_rule_match_enc_opts(const struct flow_rule *rule, struct flow_match_enc_opts *out);void flow_rule_match_ct (const struct flow_rule *rule,struct flow_match_ct *out); +void flow_rule_match_pppoe (const struct flow_rule *rule, +struct flow_match_pppoe *out);enum flow_action_id {FLOW_ACTION_ACCEPT =0 ,
net/core/flow_offload.c +7 -0
@@ -230,6 +230,13 @@ void flow_rule_match_ct(const struct flow_rule *rule, }EXPORT_SYMBOL (flow_rule_match_ct); +void flow_rule_match_pppoe (const struct flow_rule *rule, +struct flow_match_pppoe *out) +{ +FLOW_DISSECTOR_MATCH (rule,FLOW_DISSECTOR_KEY_PPPOE , out); +} +EXPORT_SYMBOL (flow_rule_match_pppoe); +struct flow_block_cb *flow_block_cb_alloc (flow_setup_cb_t *cb,void *cb_ident,void *cb_priv,void (*release)(void *cb_priv))
Signature · 1 line
2.35.1
RFC PATCH v5 4/4 ice: Add support for PPPoE hardware offload
In reply to Marcin SzycikAdd support for creating PPPoE filters in switchdev mode. Add support for parsing PPPoE and PPP-specific tc options: pppoe_sid and ppp_proto.
Example filter:
tc filter add dev $PF1 ingress protocol ppp_ses prio 1 flower pppoe_sid \
1234 ppp_proto ip skip_sw action mirred egress redirect dev $VF1_PR
Changes in iproute2 are required to use the new fields.
ICE COMMS DDP package is required to create a filter as it contains PPPoE profiles. Added a warning message when loaded DDP package does not contain required profiles.
---
v4:
* adapted code to the redefined ice_tc_pppoe_hdr (session_id is now
stored in __be16)
* removed note about missing support for vlan fields:
263957263a00 ("ice: switch: dynamically add VLAN headers to dummy packets") is already accepted
* always add an ethtype lookup if PPP/PPPoE options are provided (to prevent setting incorrect ethtype)
* rebase
v2: wrap one long line
drivers/net/ethernet/intel/ice/ice.h | 1 + .../net/ethernet/intel/ice/ice_flex_pipe.c | 5 +- .../ethernet/intel/ice/ice_protocol_type.h | 11 ++ drivers/net/ethernet/intel/ice/ice_switch.c | 165 ++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_tc_lib.c | 71 +++++++- drivers/net/ethernet/intel/ice/ice_tc_lib.h | 8 + 6 files changed, 259 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/ice/ice.h +1 -0
@@ -52,6 +52,7 @@#include <net/udp_tunnel.h> #include <net/vxlan.h> #include <net/gtp.h> +#include <linux/ppp_defs.h> #include "ice_devids.h" #include "ice_type.h" #include "ice_txrx.h"
drivers/net/ethernet/intel/ice/ice_flex_pipe.c +4 -1
@@ -1964,8 +1964,11 @@ ice_get_sw_fv_list(struct ice_hw *hw, struct ice_prot_lkup_ext *lkups, } } }while (fv); -if (list_empty (fv_list)) +if (list_empty (fv_list)) { +dev_warn (ice_hw_to_dev (hw),"Required profiles not found in currently loaded DDP package" );return -EIO ; + } +return 0 ; err:
drivers/net/ethernet/intel/ice/ice_protocol_type.h +11 -0
@@ -43,6 +43,7 @@ enum ice_protocol_type {ICE_NVGRE ,ICE_GTP ,ICE_GTP_NO_PAY , +ICE_PPPOE ,ICE_VLAN_EX ,ICE_VLAN_IN , ICE_VXLAN_GPE,
@@ -109,6 +110,7 @@ enum ice_prot_id {#define ICE_TCP_IL_HW 49#define ICE_UDP_ILOS_HW 53#define ICE_GRE_OF_HW 64 +#define ICE_PPPOE_HW 103#define ICE_UDP_OF_HW 52/* UDP Tunnels */ #define ICE_META_DATA_ID_HW 255/* this is used for tunnel and VLAN type */
@@ -207,6 +209,14 @@ struct ice_udp_gtp_hdr {u8 rsvrd; }; +struct ice_pppoe_hdr { +u8 rsrvd_ver_type; +u8 rsrvd_code; +__be16 session_id; +__be16 length; +__be16 ppp_prot_id;/* control and data only */ +}; +struct ice_nvgre_hdr {__be16 flags;__be16 protocol;
@@ -224,6 +234,7 @@ union ice_prot_hdr {struct ice_udp_tnl_hdr tnl_hdr;struct ice_nvgre_hdr nvgre_hdr;struct ice_udp_gtp_hdr gtp_hdr; +struct ice_pppoe_hdr pppoe_hdr; };/* This is mapping table entry that maps every word within a given protocol
drivers/net/ethernet/intel/ice/ice_switch.c +165 -0
207 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_tc_lib.c +70 -1
101 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_tc_lib.h +8 -0
@@ -24,6 +24,8 @@#define ICE_TC_FLWR_FIELD_ETH_TYPE_ID BIT(17)#define ICE_TC_FLWR_FIELD_ENC_OPTS BIT(18)#define ICE_TC_FLWR_FIELD_CVLAN BIT(19) +#define ICE_TC_FLWR_FIELD_PPPOE_SESSID BIT(20) +#define ICE_TC_FLWR_FIELD_PPP_PROTO BIT(21)#define ICE_TC_FLOWER_MASK_32 0xFFFFFFFF
@@ -44,6 +46,11 @@ struct ice_tc_vlan_hdr {__be16 vlan_tpid; }; +struct ice_tc_pppoe_hdr { +__be16 session_id; +__be16 ppp_proto; +}; +struct ice_tc_l2_hdr {u8 dst_mac[ETH_ALEN ];u8 src_mac[ETH_ALEN ];
@@ -84,6 +91,7 @@ struct ice_tc_flower_lyr_2_4_hdrs {struct ice_tc_l2_hdr l2_mask;struct ice_tc_vlan_hdr vlan_hdr;struct ice_tc_vlan_hdr cvlan_hdr; +struct ice_tc_pppoe_hdr pppoe_hdr;/* L3 (IPv4[6]) layer fields with their mask */ struct ice_tc_l3_hdr l3_key;struct ice_tc_l3_hdr l3_mask;
Signature · 1 line
2.35.1