nfp: change flows in apps that offload ndo_setup_tc
authorJiri Pirko <jiri@mellanox.com>
Mon, 7 Aug 2017 08:15:27 +0000 (10:15 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 7 Aug 2017 16:42:36 +0000 (09:42 -0700)
Change the flows a bit in preparation of follow-up changes in
ndo_setup_tc args. Also, change the error code to align with the rest of
the drivers.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/netronome/nfp/bpf/main.c
drivers/net/ethernet/netronome/nfp/flower/offload.c

index 788880808a6e1be06758cc6beb06533b5edb4bb0..d7975dcecb40237c2f7b13360726ecb0078697b1 100644 (file)
@@ -126,19 +126,15 @@ static int nfp_bpf_setup_tc(struct nfp_app *app, struct net_device *netdev,
 {
        struct nfp_net *nn = netdev_priv(netdev);
 
-       if (TC_H_MAJ(handle) != TC_H_MAJ(TC_H_INGRESS))
-               return -EOPNOTSUPP;
-       if (proto != htons(ETH_P_ALL))
+       if (type != TC_SETUP_CLSBPF || !nfp_net_ebpf_capable(nn) ||
+           TC_H_MAJ(handle) != TC_H_MAJ(TC_H_INGRESS) ||
+           proto != htons(ETH_P_ALL))
                return -EOPNOTSUPP;
 
-       if (type == TC_SETUP_CLSBPF && nfp_net_ebpf_capable(nn)) {
-               if (!nn->dp.bpf_offload_xdp)
-                       return nfp_net_bpf_offload(nn, tc->cls_bpf);
-               else
-                       return -EBUSY;
-       }
+       if (nn->dp.bpf_offload_xdp)
+               return -EBUSY;
 
-       return -EINVAL;
+       return nfp_net_bpf_offload(nn, tc->cls_bpf);
 }
 
 static bool nfp_bpf_tc_busy(struct nfp_app *app, struct nfp_net *nn)
index d045cf8c140a7950c77ea8d4ddd814778ac1520a..58af438a95c19ad74a9b574ed8342f41d48daa7a 100644 (file)
@@ -388,14 +388,10 @@ int nfp_flower_setup_tc(struct nfp_app *app, struct net_device *netdev,
                        enum tc_setup_type type, u32 handle, __be16 proto,
                        struct tc_to_netdev *tc)
 {
-       if (TC_H_MAJ(handle) != TC_H_MAJ(TC_H_INGRESS))
+       if (type != TC_SETUP_CLSFLOWER ||
+           TC_H_MAJ(handle) != TC_H_MAJ(TC_H_INGRESS) ||
+           !eth_proto_is_802_3(proto))
                return -EOPNOTSUPP;
 
-       if (!eth_proto_is_802_3(proto))
-               return -EOPNOTSUPP;
-
-       if (type != TC_SETUP_CLSFLOWER)
-               return -EINVAL;
-
        return nfp_flower_repr_offload(app, netdev, tc->cls_flower);
 }