cxgb4vf: Add support for Chelsio T5 adapter
authorSantosh Rastapur <santosh@chelsio.com>
Thu, 14 Mar 2013 05:08:57 +0000 (05:08 +0000)
committerDavid S. Miller <davem@davemloft.net>
Thu, 14 Mar 2013 15:35:57 +0000 (11:35 -0400)
Signed-off-by: Santosh Rastapur <santosh@chelsio.com>
Signed-off-by: Vipul Pandya <vipul@chelsio.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/chelsio/cxgb4vf/adapter.h
drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
drivers/net/ethernet/chelsio/cxgb4vf/sge.c
drivers/net/ethernet/chelsio/cxgb4vf/t4vf_common.h
drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c

index 68eaa9c88c7d8a77646bd217e00877a281254a59..be5c7ef6ca939654365b6aec6dc108e03e0f74d9 100644 (file)
@@ -344,6 +344,7 @@ struct adapter {
        unsigned long registered_device_map;
        unsigned long open_device_map;
        unsigned long flags;
+       enum chip_type chip;
        struct adapter_params params;
 
        /* queue and interrupt resources */
index 56b46ab2d4c5ae452410da4469ab7b2c86ba1894..7fcac20037695bf39aee8fa7f63a5669678bc150 100644 (file)
@@ -54,8 +54,8 @@
 /*
  * Generic information about the driver.
  */
-#define DRV_VERSION "1.0.0"
-#define DRV_DESC "Chelsio T4 Virtual Function (VF) Network Driver"
+#define DRV_VERSION "2.0.0-ko"
+#define DRV_DESC "Chelsio T4/T5 Virtual Function (VF) Network Driver"
 
 /*
  * Module Parameters.
@@ -1050,7 +1050,7 @@ static inline unsigned int mk_adap_vers(const struct adapter *adapter)
        /*
         * Chip version 4, revision 0x3f (cxgb4vf).
         */
-       return 4 | (0x3f << 10);
+       return CHELSIO_CHIP_VERSION(adapter->chip) | (0x3f << 10);
 }
 
 /*
@@ -2099,6 +2099,15 @@ static int adap_init0(struct adapter *adapter)
                return err;
        }
 
+       switch (adapter->pdev->device >> 12) {
+       case CHELSIO_T4:
+               adapter->chip = CHELSIO_CHIP_CODE(CHELSIO_T4, 0);
+               break;
+       case CHELSIO_T5:
+               adapter->chip = CHELSIO_CHIP_CODE(CHELSIO_T5, 0);
+               break;
+       }
+
        /*
         * Grab basic operational parameters.  These will predominantly have
         * been set up by the Physical Function Driver or will be hard coded
@@ -2888,6 +2897,26 @@ static struct pci_device_id cxgb4vf_pci_tbl[] = {
        CH_DEVICE(0x480a, 0),   /* T404-bt */
        CH_DEVICE(0x480d, 0),   /* T480-cr */
        CH_DEVICE(0x480e, 0),   /* T440-lp-cr */
+       CH_DEVICE(0x5800, 0),   /* T580-dbg */
+       CH_DEVICE(0x5801, 0),   /* T520-cr */
+       CH_DEVICE(0x5802, 0),   /* T522-cr */
+       CH_DEVICE(0x5803, 0),   /* T540-cr */
+       CH_DEVICE(0x5804, 0),   /* T520-bch */
+       CH_DEVICE(0x5805, 0),   /* T540-bch */
+       CH_DEVICE(0x5806, 0),   /* T540-ch */
+       CH_DEVICE(0x5807, 0),   /* T520-so */
+       CH_DEVICE(0x5808, 0),   /* T520-cx */
+       CH_DEVICE(0x5809, 0),   /* T520-bt */
+       CH_DEVICE(0x580a, 0),   /* T504-bt */
+       CH_DEVICE(0x580b, 0),   /* T520-sr */
+       CH_DEVICE(0x580c, 0),   /* T504-bt */
+       CH_DEVICE(0x580d, 0),   /* T580-cr */
+       CH_DEVICE(0x580e, 0),   /* T540-lp-cr */
+       CH_DEVICE(0x580f, 0),   /* Amsterdam */
+       CH_DEVICE(0x5810, 0),   /* T580-lp-cr */
+       CH_DEVICE(0x5811, 0),   /* T520-lp-cr */
+       CH_DEVICE(0x5812, 0),   /* T560-cr */
+       CH_DEVICE(0x5813, 0),   /* T580-cr */
        { 0, }
 };
 
index 9488032d6d2d568239a0d940a9ca893359d40b4d..61dfb2a4792989da01e824de2c256f29dc4ac661 100644 (file)
@@ -528,17 +528,21 @@ static void unmap_rx_buf(struct adapter *adapter, struct sge_fl *fl)
  */
 static inline void ring_fl_db(struct adapter *adapter, struct sge_fl *fl)
 {
+       u32 val;
+
        /*
         * The SGE keeps track of its Producer and Consumer Indices in terms
         * of Egress Queue Units so we can only tell it about integral numbers
         * of multiples of Free List Entries per Egress Queue Units ...
         */
        if (fl->pend_cred >= FL_PER_EQ_UNIT) {
+               val = PIDX(fl->pend_cred / FL_PER_EQ_UNIT);
+               if (!is_t4(adapter->chip))
+                       val |= DBTYPE(1);
                wmb();
                t4_write_reg(adapter, T4VF_SGE_BASE_ADDR + SGE_VF_KDOORBELL,
                             DBPRIO(1) |
-                            QID(fl->cntxt_id) |
-                            PIDX(fl->pend_cred / FL_PER_EQ_UNIT));
+                            QID(fl->cntxt_id) | val);
                fl->pend_cred %= FL_PER_EQ_UNIT;
        }
 }
index 283f9d0d37fd4e4b689e698f965036ba6cda40e2..53cbfed21d0b9871fe257ee75836dc2dadbdc185 100644 (file)
 
 #include "../cxgb4/t4fw_api.h"
 
+#define CHELSIO_CHIP_CODE(version, revision) (((version) << 4) | (revision))
+#define CHELSIO_CHIP_VERSION(code) ((code) >> 4)
+#define CHELSIO_CHIP_RELEASE(code) ((code) & 0xf)
+
+#define CHELSIO_T4             0x4
+#define CHELSIO_T5             0x5
+
+enum chip_type {
+       T4_A1 = CHELSIO_CHIP_CODE(CHELSIO_T4, 0),
+       T4_A2 = CHELSIO_CHIP_CODE(CHELSIO_T4, 1),
+       T4_A3 = CHELSIO_CHIP_CODE(CHELSIO_T4, 2),
+       T4_FIRST_REV    = T4_A1,
+       T4_LAST_REV     = T4_A3,
+
+       T5_A1 = CHELSIO_CHIP_CODE(CHELSIO_T5, 0),
+       T5_FIRST_REV    = T5_A1,
+       T5_LAST_REV     = T5_A1,
+};
+
 /*
  * The "len16" field of a Firmware Command Structure ...
  */
@@ -232,6 +251,11 @@ static inline int t4vf_wr_mbox_ns(struct adapter *adapter, const void *cmd,
        return t4vf_wr_mbox_core(adapter, cmd, size, rpl, false);
 }
 
+static inline int is_t4(enum chip_type chip)
+{
+       return (chip >= T4_FIRST_REV && chip <= T4_LAST_REV);
+}
+
 int t4vf_wait_dev_ready(struct adapter *);
 int t4vf_port_init(struct adapter *, int);
 
index 7127c7b9efdeb59474554b70c71b52754a26bc24..9f96dc3bb11203e0781faa785d12ec31df4f76f3 100644 (file)
@@ -1027,8 +1027,11 @@ int t4vf_alloc_mac_filt(struct adapter *adapter, unsigned int viid, bool free,
        unsigned nfilters = 0;
        unsigned int rem = naddr;
        struct fw_vi_mac_cmd cmd, rpl;
+       unsigned int max_naddr = is_t4(adapter->chip) ?
+                                NUM_MPS_CLS_SRAM_L_INSTANCES :
+                                NUM_MPS_T5_CLS_SRAM_L_INSTANCES;
 
-       if (naddr > FW_CLS_TCAM_NUM_ENTRIES)
+       if (naddr > max_naddr)
                return -EINVAL;
 
        for (offset = 0; offset < naddr; /**/) {
@@ -1069,10 +1072,10 @@ int t4vf_alloc_mac_filt(struct adapter *adapter, unsigned int viid, bool free,
 
                        if (idx)
                                idx[offset+i] =
-                                       (index >= FW_CLS_TCAM_NUM_ENTRIES
+                                       (index >= max_naddr
                                         ? 0xffff
                                         : index);
-                       if (index < FW_CLS_TCAM_NUM_ENTRIES)
+                       if (index < max_naddr)
                                nfilters++;
                        else if (hash)
                                *hash |= (1ULL << hash_mac_addr(addr[offset+i]));
@@ -1118,6 +1121,9 @@ int t4vf_change_mac(struct adapter *adapter, unsigned int viid,
        struct fw_vi_mac_exact *p = &cmd.u.exact[0];
        size_t len16 = DIV_ROUND_UP(offsetof(struct fw_vi_mac_cmd,
                                             u.exact[1]), 16);
+       unsigned int max_naddr = is_t4(adapter->chip) ?
+                                NUM_MPS_CLS_SRAM_L_INSTANCES :
+                                NUM_MPS_T5_CLS_SRAM_L_INSTANCES;
 
        /*
         * If this is a new allocation, determine whether it should be
@@ -1140,7 +1146,7 @@ int t4vf_change_mac(struct adapter *adapter, unsigned int viid,
        if (ret == 0) {
                p = &rpl.u.exact[0];
                ret = FW_VI_MAC_CMD_IDX_GET(be16_to_cpu(p->valid_to_idx));
-               if (ret >= FW_CLS_TCAM_NUM_ENTRIES)
+               if (ret >= max_naddr)
                        ret = -ENOMEM;
        }
        return ret;