Commit f8b7b0a6 authored by Pieter Jansen van Vuuren's avatar Pieter Jansen van Vuuren Committed by David S. Miller

nfp: add set tcp and udp header action flower offload

Previously we did not have offloading support for set TCP/UDP actions. This
patch enables TC flower offload of set TCP/UDP sport and dport actions.
Signed-off-by: default avatarPieter Jansen van Vuuren <pieter.jansenvanvuuren@netronome.com>
Reviewed-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: default avatarSimon Horman <simon.horman@netronome.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 354b82bb
...@@ -347,11 +347,40 @@ nfp_fl_set_ip6(const struct tc_action *action, int idx, u32 off, ...@@ -347,11 +347,40 @@ nfp_fl_set_ip6(const struct tc_action *action, int idx, u32 off,
return 0; return 0;
} }
static int
nfp_fl_set_tport(const struct tc_action *action, int idx, u32 off,
struct nfp_fl_set_tport *set_tport, int opcode)
{
u32 exact, mask;
u16 tmp_set_op;
if (off)
return -EOPNOTSUPP;
mask = ~tcf_pedit_mask(action, idx);
exact = tcf_pedit_val(action, idx);
if (exact & ~mask)
return -EOPNOTSUPP;
nfp_fl_set_helper32(exact, mask, set_tport->tp_port_val,
set_tport->tp_port_mask);
set_tport->reserved = cpu_to_be16(0);
tmp_set_op = FIELD_PREP(NFP_FL_ACT_LEN_LW,
sizeof(*set_tport) >> NFP_FL_LW_SIZ);
tmp_set_op |= FIELD_PREP(NFP_FL_ACT_JMP_ID, opcode);
set_tport->a_op = cpu_to_be16(tmp_set_op);
return 0;
}
static int static int
nfp_fl_pedit(const struct tc_action *action, char *nfp_action, int *a_len) nfp_fl_pedit(const struct tc_action *action, char *nfp_action, int *a_len)
{ {
struct nfp_fl_set_ipv6_addr set_ip6_dst, set_ip6_src; struct nfp_fl_set_ipv6_addr set_ip6_dst, set_ip6_src;
struct nfp_fl_set_ip4_addrs set_ip_addr; struct nfp_fl_set_ip4_addrs set_ip_addr;
struct nfp_fl_set_tport set_tport;
struct nfp_fl_set_eth set_eth; struct nfp_fl_set_eth set_eth;
enum pedit_header_type htype; enum pedit_header_type htype;
int idx, nkeys, err; int idx, nkeys, err;
...@@ -361,6 +390,7 @@ nfp_fl_pedit(const struct tc_action *action, char *nfp_action, int *a_len) ...@@ -361,6 +390,7 @@ nfp_fl_pedit(const struct tc_action *action, char *nfp_action, int *a_len)
memset(&set_ip6_dst, 0, sizeof(set_ip6_dst)); memset(&set_ip6_dst, 0, sizeof(set_ip6_dst));
memset(&set_ip6_src, 0, sizeof(set_ip6_src)); memset(&set_ip6_src, 0, sizeof(set_ip6_src));
memset(&set_ip_addr, 0, sizeof(set_ip_addr)); memset(&set_ip_addr, 0, sizeof(set_ip_addr));
memset(&set_tport, 0, sizeof(set_tport));
memset(&set_eth, 0, sizeof(set_eth)); memset(&set_eth, 0, sizeof(set_eth));
nkeys = tcf_pedit_nkeys(action); nkeys = tcf_pedit_nkeys(action);
...@@ -383,6 +413,14 @@ nfp_fl_pedit(const struct tc_action *action, char *nfp_action, int *a_len) ...@@ -383,6 +413,14 @@ nfp_fl_pedit(const struct tc_action *action, char *nfp_action, int *a_len)
err = nfp_fl_set_ip6(action, idx, offset, &set_ip6_dst, err = nfp_fl_set_ip6(action, idx, offset, &set_ip6_dst,
&set_ip6_src); &set_ip6_src);
break; break;
case TCA_PEDIT_KEY_EX_HDR_TYPE_TCP:
err = nfp_fl_set_tport(action, idx, offset, &set_tport,
NFP_FL_ACTION_OPCODE_SET_TCP);
break;
case TCA_PEDIT_KEY_EX_HDR_TYPE_UDP:
err = nfp_fl_set_tport(action, idx, offset, &set_tport,
NFP_FL_ACTION_OPCODE_SET_UDP);
break;
default: default:
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
...@@ -418,6 +456,10 @@ nfp_fl_pedit(const struct tc_action *action, char *nfp_action, int *a_len) ...@@ -418,6 +456,10 @@ nfp_fl_pedit(const struct tc_action *action, char *nfp_action, int *a_len)
act_size = sizeof(set_ip6_src); act_size = sizeof(set_ip6_src);
memcpy(nfp_action, &set_ip6_src, act_size); memcpy(nfp_action, &set_ip6_src, act_size);
*a_len += act_size; *a_len += act_size;
} else if (set_tport.a_op) {
act_size = sizeof(set_tport);
memcpy(nfp_action, &set_tport, act_size);
*a_len += act_size;
} }
return 0; return 0;
......
...@@ -81,6 +81,8 @@ ...@@ -81,6 +81,8 @@
#define NFP_FL_ACTION_OPCODE_SET_IPV4_ADDRS 9 #define NFP_FL_ACTION_OPCODE_SET_IPV4_ADDRS 9
#define NFP_FL_ACTION_OPCODE_SET_IPV6_SRC 11 #define NFP_FL_ACTION_OPCODE_SET_IPV6_SRC 11
#define NFP_FL_ACTION_OPCODE_SET_IPV6_DST 12 #define NFP_FL_ACTION_OPCODE_SET_IPV6_DST 12
#define NFP_FL_ACTION_OPCODE_SET_UDP 14
#define NFP_FL_ACTION_OPCODE_SET_TCP 15
#define NFP_FL_ACTION_OPCODE_PRE_TUNNEL 17 #define NFP_FL_ACTION_OPCODE_PRE_TUNNEL 17
#define NFP_FL_ACTION_OPCODE_NUM 32 #define NFP_FL_ACTION_OPCODE_NUM 32
...@@ -136,6 +138,13 @@ struct nfp_fl_set_ipv6_addr { ...@@ -136,6 +138,13 @@ struct nfp_fl_set_ipv6_addr {
} ipv6[4]; } ipv6[4];
}; };
struct nfp_fl_set_tport {
__be16 a_op;
__be16 reserved;
u8 tp_port_mask[4];
u8 tp_port_val[4];
};
struct nfp_fl_output { struct nfp_fl_output {
__be16 a_op; __be16 a_op;
__be16 flags; __be16 flags;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment