net: ixgbe: abort with cls u32 divisor groups greater than 1
authorJohn Fastabend <john.fastabend@gmail.com>
Wed, 17 Feb 2016 05:19:19 +0000 (21:19 -0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 17 Feb 2016 14:47:37 +0000 (09:47 -0500)
This patch ensures ixgbe will not try to offload hash tables from the
u32 module. The device class does not currently support this so until
it is enabled just abort on these tables.

Interestingly the more flexible your hardware is the less code you
need to implement to guard against these cases.

Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/intel/ixgbe/ixgbe.h
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c

index fc877c715c6488291072859a2a1fe8f033abddd3..84fa28ceb200c968ad8422ca5194cf8dfb3dc13c 100644 (file)
@@ -798,6 +798,7 @@ struct ixgbe_adapter {
 
 #define IXGBE_MAX_LINK_HANDLE 10
        struct ixgbe_mat_field *jump_tables[IXGBE_MAX_LINK_HANDLE];
+       unsigned long tables;
 
 /* maximum number of RETA entries among all devices supported by ixgbe
  * driver: currently it's x550 device in non-SRIOV mode
index abdfaead1ba144509905aa8fa49cc2a0d4108388..cf4b729c92d7655d5928da9eefbebd56af85e645 100644 (file)
@@ -8217,6 +8217,27 @@ static int ixgbe_delete_clsu32(struct ixgbe_adapter *adapter,
        return err;
 }
 
+static int ixgbe_configure_clsu32_add_hnode(struct ixgbe_adapter *adapter,
+                                           __be16 protocol,
+                                           struct tc_cls_u32_offload *cls)
+{
+       /* This ixgbe devices do not support hash tables at the moment
+        * so abort when given hash tables.
+        */
+       if (cls->hnode.divisor > 0)
+               return -EINVAL;
+
+       set_bit(TC_U32_USERHTID(cls->hnode.handle), &adapter->tables);
+       return 0;
+}
+
+static int ixgbe_configure_clsu32_del_hnode(struct ixgbe_adapter *adapter,
+                                           struct tc_cls_u32_offload *cls)
+{
+       clear_bit(TC_U32_USERHTID(cls->hnode.handle), &adapter->tables);
+       return 0;
+}
+
 static int ixgbe_configure_clsu32(struct ixgbe_adapter *adapter,
                                  __be16 protocol,
                                  struct tc_cls_u32_offload *cls)
@@ -8251,6 +8272,9 @@ static int ixgbe_configure_clsu32(struct ixgbe_adapter *adapter,
                struct ixgbe_nexthdr *nexthdr = ixgbe_ipv4_jumps;
                u32 uhtid = TC_U32_USERHTID(cls->knode.link_handle);
 
+               if (!test_bit(uhtid, &adapter->tables))
+                       return -EINVAL;
+
                for (i = 0; nexthdr[i].jump; i++) {
                        if (nexthdr->o != cls->knode.sel->offoff ||
                            nexthdr->s != cls->knode.sel->offshift ||
@@ -8386,6 +8410,13 @@ int __ixgbe_setup_tc(struct net_device *dev, u32 handle, __be16 proto,
                                                      proto, tc->cls_u32);
                case TC_CLSU32_DELETE_KNODE:
                        return ixgbe_delete_clsu32(adapter, tc->cls_u32);
+               case TC_CLSU32_NEW_HNODE:
+               case TC_CLSU32_REPLACE_HNODE:
+                       return ixgbe_configure_clsu32_add_hnode(adapter, proto,
+                                                               tc->cls_u32);
+               case TC_CLSU32_DELETE_HNODE:
+                       return ixgbe_configure_clsu32_del_hnode(adapter,
+                                                               tc->cls_u32);
                default:
                        return -EINVAL;
                }