Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dledford/rdma
[firefly-linux-kernel-4.4.55.git] / drivers / net / ethernet / chelsio / cxgb4 / cxgb4_main.c
index 2cf81857a2971b280005715992c0842e4f21385f..0d147610a06f13819bd1425984f6ec6b3c34e81a 100644 (file)
@@ -1940,6 +1940,28 @@ unsigned int cxgb4_best_aligned_mtu(const unsigned short *mtus,
 }
 EXPORT_SYMBOL(cxgb4_best_aligned_mtu);
 
+/**
+ *     cxgb4_tp_smt_idx - Get the Source Mac Table index for this VI
+ *     @chip: chip type
+ *     @viid: VI id of the given port
+ *
+ *     Return the SMT index for this VI.
+ */
+unsigned int cxgb4_tp_smt_idx(enum chip_type chip, unsigned int viid)
+{
+       /* In T4/T5, SMT contains 256 SMAC entries organized in
+        * 128 rows of 2 entries each.
+        * In T6, SMT contains 256 SMAC entries in 256 rows.
+        * TODO: The below code needs to be updated when we add support
+        * for 256 VFs.
+        */
+       if (CHELSIO_CHIP_VERSION(chip) <= CHELSIO_T5)
+               return ((viid & 0x7f) << 1);
+       else
+               return (viid & 0x7f);
+}
+EXPORT_SYMBOL(cxgb4_tp_smt_idx);
+
 /**
  *     cxgb4_port_chan - get the HW channel of a port
  *     @dev: the net device for the port