nfp: bpf: add support for legacy redirect action
authorJakub Kicinski <jakub.kicinski@netronome.com>
Wed, 21 Sep 2016 10:44:06 +0000 (11:44 +0100)
committerDavid S. Miller <davem@davemloft.net>
Wed, 21 Sep 2016 23:50:03 +0000 (19:50 -0400)
Data path has redirect support so expressing redirect
to the port frame came from is a trivial matter of
setting the right result code.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/netronome/nfp/nfp_bpf.h
drivers/net/ethernet/netronome/nfp/nfp_bpf_jit.c
drivers/net/ethernet/netronome/nfp/nfp_net_offload.c

index 2adb1d80c7b72a8d433dbfac87c40a1f6f42c702..adbe0235d98eccba15218f129d88d5e68a6f6216 100644 (file)
@@ -60,6 +60,7 @@ enum static_regs {
 
 enum nfp_bpf_action_type {
        NN_ACT_TC_DROP,
+       NN_ACT_TC_REDIR,
 };
 
 /* Software register representation, hardware encoding in asm.h */
index 368381f0357fd19d1fbfdd2e201874c1c478f134..434bef975c58d6a363999fc89247006c0eda4816 100644 (file)
@@ -1440,6 +1440,7 @@ static void nfp_outro_tc_legacy(struct nfp_prog *nfp_prog)
 {
        const u8 act2code[] = {
                [NN_ACT_TC_DROP]  = 0x22,
+               [NN_ACT_TC_REDIR] = 0x24
        };
        /* Target for aborts */
        nfp_prog->tgt_abort = nfp_prog_current_offset(nfp_prog);
@@ -1468,6 +1469,7 @@ static void nfp_outro(struct nfp_prog *nfp_prog)
 {
        switch (nfp_prog->act) {
        case NN_ACT_TC_DROP:
+       case NN_ACT_TC_REDIR:
                nfp_outro_tc_legacy(nfp_prog);
                break;
        }
index 0537a53e217476e5ff38e0a0000f53c3ab196bcf..1ec8e5b74651c1f5c320b91bda564ba180354217 100644 (file)
@@ -123,6 +123,10 @@ nfp_net_bpf_get_act(struct nfp_net *nn, struct tc_cls_bpf_offload *cls_bpf)
        list_for_each_entry(a, &actions, list) {
                if (is_tcf_gact_shot(a))
                        return NN_ACT_TC_DROP;
+
+               if (is_tcf_mirred_redirect(a) &&
+                   tcf_mirred_ifindex(a) == nn->netdev->ifindex)
+                       return NN_ACT_TC_REDIR;
        }
 
        return -ENOTSUPP;