diff options
author | Jiri Pirko <jiri@mellanox.com> | 2017-10-19 09:50:45 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-10-20 22:04:08 -0400 |
commit | 6b3eb752b4b9481868b3393f06a236a1aedfa43f (patch) | |
tree | 68d1c0c1def5acb35119327e5d2a35d90e09f3cf | |
parent | 90d97315b3e774450f06c035903fed246781fe35 (diff) |
dsa: Convert ndo_setup_tc offloads to block callbacks
Benefit from the newly introduced block callback infrastructure and
convert ndo_setup_tc calls for matchall offloads to block callbacks.
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/dsa/slave.c | 64 |
1 files changed, 53 insertions, 11 deletions
diff --git a/net/dsa/slave.c b/net/dsa/slave.c index 6906de0f0050..80142918d5d1 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c | |||
@@ -777,17 +777,9 @@ static void dsa_slave_del_cls_matchall(struct net_device *dev, | |||
777 | } | 777 | } |
778 | 778 | ||
779 | static int dsa_slave_setup_tc_cls_matchall(struct net_device *dev, | 779 | static int dsa_slave_setup_tc_cls_matchall(struct net_device *dev, |
780 | struct tc_cls_matchall_offload *cls) | 780 | struct tc_cls_matchall_offload *cls, |
781 | bool ingress) | ||
781 | { | 782 | { |
782 | bool ingress; | ||
783 | |||
784 | if (is_classid_clsact_ingress(cls->common.classid)) | ||
785 | ingress = true; | ||
786 | else if (is_classid_clsact_egress(cls->common.classid)) | ||
787 | ingress = false; | ||
788 | else | ||
789 | return -EOPNOTSUPP; | ||
790 | |||
791 | if (cls->common.chain_index) | 783 | if (cls->common.chain_index) |
792 | return -EOPNOTSUPP; | 784 | return -EOPNOTSUPP; |
793 | 785 | ||
@@ -802,12 +794,62 @@ static int dsa_slave_setup_tc_cls_matchall(struct net_device *dev, | |||
802 | } | 794 | } |
803 | } | 795 | } |
804 | 796 | ||
797 | static int dsa_slave_setup_tc_block_cb(enum tc_setup_type type, void *type_data, | ||
798 | void *cb_priv, bool ingress) | ||
799 | { | ||
800 | struct net_device *dev = cb_priv; | ||
801 | |||
802 | switch (type) { | ||
803 | case TC_SETUP_CLSMATCHALL: | ||
804 | return dsa_slave_setup_tc_cls_matchall(dev, type_data, ingress); | ||
805 | default: | ||
806 | return -EOPNOTSUPP; | ||
807 | } | ||
808 | } | ||
809 | |||
810 | static int dsa_slave_setup_tc_block_cb_ig(enum tc_setup_type type, | ||
811 | void *type_data, void *cb_priv) | ||
812 | { | ||
813 | return dsa_slave_setup_tc_block_cb(type, type_data, cb_priv, true); | ||
814 | } | ||
815 | |||
816 | static int dsa_slave_setup_tc_block_cb_eg(enum tc_setup_type type, | ||
817 | void *type_data, void *cb_priv) | ||
818 | { | ||
819 | return dsa_slave_setup_tc_block_cb(type, type_data, cb_priv, false); | ||
820 | } | ||
821 | |||
822 | static int dsa_slave_setup_tc_block(struct net_device *dev, | ||
823 | struct tc_block_offload *f) | ||
824 | { | ||
825 | tc_setup_cb_t *cb; | ||
826 | |||
827 | if (f->binder_type == TCF_BLOCK_BINDER_TYPE_CLSACT_INGRESS) | ||
828 | cb = dsa_slave_setup_tc_block_cb_ig; | ||
829 | else if (f->binder_type == TCF_BLOCK_BINDER_TYPE_CLSACT_EGRESS) | ||
830 | cb = dsa_slave_setup_tc_block_cb_eg; | ||
831 | else | ||
832 | return -EOPNOTSUPP; | ||
833 | |||
834 | switch (f->command) { | ||
835 | case TC_BLOCK_BIND: | ||
836 | return tcf_block_cb_register(f->block, cb, dev, dev); | ||
837 | case TC_BLOCK_UNBIND: | ||
838 | tcf_block_cb_unregister(f->block, cb, dev); | ||
839 | return 0; | ||
840 | default: | ||
841 | return -EOPNOTSUPP; | ||
842 | } | ||
843 | } | ||
844 | |||
805 | static int dsa_slave_setup_tc(struct net_device *dev, enum tc_setup_type type, | 845 | static int dsa_slave_setup_tc(struct net_device *dev, enum tc_setup_type type, |
806 | void *type_data) | 846 | void *type_data) |
807 | { | 847 | { |
808 | switch (type) { | 848 | switch (type) { |
809 | case TC_SETUP_CLSMATCHALL: | 849 | case TC_SETUP_CLSMATCHALL: |
810 | return dsa_slave_setup_tc_cls_matchall(dev, type_data); | 850 | return 0; /* will be removed after conversion from ndo */ |
851 | case TC_SETUP_BLOCK: | ||
852 | return dsa_slave_setup_tc_block(dev, type_data); | ||
811 | default: | 853 | default: |
812 | return -EOPNOTSUPP; | 854 | return -EOPNOTSUPP; |
813 | } | 855 | } |