diff options
author | Hariprasad Shenai <hariprasad@chelsio.com> | 2013-12-03 06:35:56 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-12-03 16:55:40 -0500 |
commit | d14807dd8e7eaa41a8fee5fc3acbdaf2a0258b76 (patch) | |
tree | 069fd7c30e44064cb7235ab35bb3d25a84445ce0 /drivers/net/ethernet/chelsio | |
parent | 1b85ee09aac2f32f24b8db72eb152089b92ace87 (diff) |
cxgb4: Much cleaner implementation of is_t4()/is_t5()
Signed-off-by: Hariprasad Shenai <hariprasad@chelsio.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/chelsio')
-rw-r--r-- | drivers/net/ethernet/chelsio/cxgb4/cxgb4.h | 45 | ||||
-rw-r--r-- | drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 40 | ||||
-rw-r--r-- | drivers/net/ethernet/chelsio/cxgb4/sge.c | 12 | ||||
-rw-r--r-- | drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | 41 | ||||
-rw-r--r-- | drivers/net/ethernet/chelsio/cxgb4/t4_regs.h | 5 |
5 files changed, 73 insertions, 70 deletions
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h index ecd2fb3ef695..9710a16a26e0 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h | |||
@@ -240,6 +240,26 @@ struct pci_params { | |||
240 | unsigned char width; | 240 | unsigned char width; |
241 | }; | 241 | }; |
242 | 242 | ||
243 | #define CHELSIO_CHIP_CODE(version, revision) (((version) << 4) | (revision)) | ||
244 | #define CHELSIO_CHIP_FPGA 0x100 | ||
245 | #define CHELSIO_CHIP_VERSION(code) (((code) >> 4) & 0xf) | ||
246 | #define CHELSIO_CHIP_RELEASE(code) ((code) & 0xf) | ||
247 | |||
248 | #define CHELSIO_T4 0x4 | ||
249 | #define CHELSIO_T5 0x5 | ||
250 | |||
251 | enum chip_type { | ||
252 | T4_A1 = CHELSIO_CHIP_CODE(CHELSIO_T4, 1), | ||
253 | T4_A2 = CHELSIO_CHIP_CODE(CHELSIO_T4, 2), | ||
254 | T4_FIRST_REV = T4_A1, | ||
255 | T4_LAST_REV = T4_A2, | ||
256 | |||
257 | T5_A0 = CHELSIO_CHIP_CODE(CHELSIO_T5, 0), | ||
258 | T5_A1 = CHELSIO_CHIP_CODE(CHELSIO_T5, 1), | ||
259 | T5_FIRST_REV = T5_A0, | ||
260 | T5_LAST_REV = T5_A1, | ||
261 | }; | ||
262 | |||
243 | struct adapter_params { | 263 | struct adapter_params { |
244 | struct tp_params tp; | 264 | struct tp_params tp; |
245 | struct vpd_params vpd; | 265 | struct vpd_params vpd; |
@@ -259,7 +279,7 @@ struct adapter_params { | |||
259 | 279 | ||
260 | unsigned char nports; /* # of ethernet ports */ | 280 | unsigned char nports; /* # of ethernet ports */ |
261 | unsigned char portvec; | 281 | unsigned char portvec; |
262 | unsigned char rev; /* chip revision */ | 282 | enum chip_type chip; /* chip code */ |
263 | unsigned char offload; | 283 | unsigned char offload; |
264 | 284 | ||
265 | unsigned char bypass; | 285 | unsigned char bypass; |
@@ -512,25 +532,6 @@ struct sge { | |||
512 | 532 | ||
513 | struct l2t_data; | 533 | struct l2t_data; |
514 | 534 | ||
515 | #define CHELSIO_CHIP_CODE(version, revision) (((version) << 4) | (revision)) | ||
516 | #define CHELSIO_CHIP_VERSION(code) ((code) >> 4) | ||
517 | #define CHELSIO_CHIP_RELEASE(code) ((code) & 0xf) | ||
518 | |||
519 | #define CHELSIO_T4 0x4 | ||
520 | #define CHELSIO_T5 0x5 | ||
521 | |||
522 | enum chip_type { | ||
523 | T4_A1 = CHELSIO_CHIP_CODE(CHELSIO_T4, 0), | ||
524 | T4_A2 = CHELSIO_CHIP_CODE(CHELSIO_T4, 1), | ||
525 | T4_A3 = CHELSIO_CHIP_CODE(CHELSIO_T4, 2), | ||
526 | T4_FIRST_REV = T4_A1, | ||
527 | T4_LAST_REV = T4_A3, | ||
528 | |||
529 | T5_A1 = CHELSIO_CHIP_CODE(CHELSIO_T5, 0), | ||
530 | T5_FIRST_REV = T5_A1, | ||
531 | T5_LAST_REV = T5_A1, | ||
532 | }; | ||
533 | |||
534 | #ifdef CONFIG_PCI_IOV | 535 | #ifdef CONFIG_PCI_IOV |
535 | 536 | ||
536 | /* T4 supports SRIOV on PF0-3 and T5 on PF0-7. However, the Serial | 537 | /* T4 supports SRIOV on PF0-3 and T5 on PF0-7. However, the Serial |
@@ -715,12 +716,12 @@ enum { | |||
715 | 716 | ||
716 | static inline int is_t5(enum chip_type chip) | 717 | static inline int is_t5(enum chip_type chip) |
717 | { | 718 | { |
718 | return (chip >= T5_FIRST_REV && chip <= T5_LAST_REV); | 719 | return CHELSIO_CHIP_VERSION(chip) == CHELSIO_T5; |
719 | } | 720 | } |
720 | 721 | ||
721 | static inline int is_t4(enum chip_type chip) | 722 | static inline int is_t4(enum chip_type chip) |
722 | { | 723 | { |
723 | return (chip >= T4_FIRST_REV && chip <= T4_LAST_REV); | 724 | return CHELSIO_CHIP_VERSION(chip) == CHELSIO_T4; |
724 | } | 725 | } |
725 | 726 | ||
726 | static inline u32 t4_read_reg(struct adapter *adap, u32 reg_addr) | 727 | static inline u32 t4_read_reg(struct adapter *adap, u32 reg_addr) |
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c index 8b929eeecd2d..35933cd18e0f 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | |||
@@ -1083,7 +1083,7 @@ static int upgrade_fw(struct adapter *adap) | |||
1083 | struct device *dev = adap->pdev_dev; | 1083 | struct device *dev = adap->pdev_dev; |
1084 | char *fw_file_name; | 1084 | char *fw_file_name; |
1085 | 1085 | ||
1086 | switch (CHELSIO_CHIP_VERSION(adap->chip)) { | 1086 | switch (CHELSIO_CHIP_VERSION(adap->params.chip)) { |
1087 | case CHELSIO_T4: | 1087 | case CHELSIO_T4: |
1088 | fw_file_name = FW_FNAME; | 1088 | fw_file_name = FW_FNAME; |
1089 | exp_major = FW_VERSION_MAJOR; | 1089 | exp_major = FW_VERSION_MAJOR; |
@@ -1093,7 +1093,7 @@ static int upgrade_fw(struct adapter *adap) | |||
1093 | exp_major = FW_VERSION_MAJOR_T5; | 1093 | exp_major = FW_VERSION_MAJOR_T5; |
1094 | break; | 1094 | break; |
1095 | default: | 1095 | default: |
1096 | dev_err(dev, "Unsupported chip type, %x\n", adap->chip); | 1096 | dev_err(dev, "Unsupported chip type, %x\n", adap->params.chip); |
1097 | return -EINVAL; | 1097 | return -EINVAL; |
1098 | } | 1098 | } |
1099 | 1099 | ||
@@ -1415,7 +1415,7 @@ static int get_sset_count(struct net_device *dev, int sset) | |||
1415 | static int get_regs_len(struct net_device *dev) | 1415 | static int get_regs_len(struct net_device *dev) |
1416 | { | 1416 | { |
1417 | struct adapter *adap = netdev2adap(dev); | 1417 | struct adapter *adap = netdev2adap(dev); |
1418 | if (is_t4(adap->chip)) | 1418 | if (is_t4(adap->params.chip)) |
1419 | return T4_REGMAP_SIZE; | 1419 | return T4_REGMAP_SIZE; |
1420 | else | 1420 | else |
1421 | return T5_REGMAP_SIZE; | 1421 | return T5_REGMAP_SIZE; |
@@ -1499,7 +1499,7 @@ static void get_stats(struct net_device *dev, struct ethtool_stats *stats, | |||
1499 | data += sizeof(struct port_stats) / sizeof(u64); | 1499 | data += sizeof(struct port_stats) / sizeof(u64); |
1500 | collect_sge_port_stats(adapter, pi, (struct queue_port_stats *)data); | 1500 | collect_sge_port_stats(adapter, pi, (struct queue_port_stats *)data); |
1501 | data += sizeof(struct queue_port_stats) / sizeof(u64); | 1501 | data += sizeof(struct queue_port_stats) / sizeof(u64); |
1502 | if (!is_t4(adapter->chip)) { | 1502 | if (!is_t4(adapter->params.chip)) { |
1503 | t4_write_reg(adapter, SGE_STAT_CFG, STATSOURCE_T5(7)); | 1503 | t4_write_reg(adapter, SGE_STAT_CFG, STATSOURCE_T5(7)); |
1504 | val1 = t4_read_reg(adapter, SGE_STAT_TOTAL); | 1504 | val1 = t4_read_reg(adapter, SGE_STAT_TOTAL); |
1505 | val2 = t4_read_reg(adapter, SGE_STAT_MATCH); | 1505 | val2 = t4_read_reg(adapter, SGE_STAT_MATCH); |
@@ -1521,8 +1521,8 @@ static void get_stats(struct net_device *dev, struct ethtool_stats *stats, | |||
1521 | */ | 1521 | */ |
1522 | static inline unsigned int mk_adap_vers(const struct adapter *ap) | 1522 | static inline unsigned int mk_adap_vers(const struct adapter *ap) |
1523 | { | 1523 | { |
1524 | return CHELSIO_CHIP_VERSION(ap->chip) | | 1524 | return CHELSIO_CHIP_VERSION(ap->params.chip) | |
1525 | (CHELSIO_CHIP_RELEASE(ap->chip) << 10) | (1 << 16); | 1525 | (CHELSIO_CHIP_RELEASE(ap->params.chip) << 10) | (1 << 16); |
1526 | } | 1526 | } |
1527 | 1527 | ||
1528 | static void reg_block_dump(struct adapter *ap, void *buf, unsigned int start, | 1528 | static void reg_block_dump(struct adapter *ap, void *buf, unsigned int start, |
@@ -2189,7 +2189,7 @@ static void get_regs(struct net_device *dev, struct ethtool_regs *regs, | |||
2189 | static const unsigned int *reg_ranges; | 2189 | static const unsigned int *reg_ranges; |
2190 | int arr_size = 0, buf_size = 0; | 2190 | int arr_size = 0, buf_size = 0; |
2191 | 2191 | ||
2192 | if (is_t4(ap->chip)) { | 2192 | if (is_t4(ap->params.chip)) { |
2193 | reg_ranges = &t4_reg_ranges[0]; | 2193 | reg_ranges = &t4_reg_ranges[0]; |
2194 | arr_size = ARRAY_SIZE(t4_reg_ranges); | 2194 | arr_size = ARRAY_SIZE(t4_reg_ranges); |
2195 | buf_size = T4_REGMAP_SIZE; | 2195 | buf_size = T4_REGMAP_SIZE; |
@@ -2967,7 +2967,7 @@ static int setup_debugfs(struct adapter *adap) | |||
2967 | size = t4_read_reg(adap, MA_EDRAM1_BAR); | 2967 | size = t4_read_reg(adap, MA_EDRAM1_BAR); |
2968 | add_debugfs_mem(adap, "edc1", MEM_EDC1, EDRAM_SIZE_GET(size)); | 2968 | add_debugfs_mem(adap, "edc1", MEM_EDC1, EDRAM_SIZE_GET(size)); |
2969 | } | 2969 | } |
2970 | if (is_t4(adap->chip)) { | 2970 | if (is_t4(adap->params.chip)) { |
2971 | size = t4_read_reg(adap, MA_EXT_MEMORY_BAR); | 2971 | size = t4_read_reg(adap, MA_EXT_MEMORY_BAR); |
2972 | if (i & EXT_MEM_ENABLE) | 2972 | if (i & EXT_MEM_ENABLE) |
2973 | add_debugfs_mem(adap, "mc", MEM_MC, | 2973 | add_debugfs_mem(adap, "mc", MEM_MC, |
@@ -3419,7 +3419,7 @@ unsigned int cxgb4_dbfifo_count(const struct net_device *dev, int lpfifo) | |||
3419 | 3419 | ||
3420 | v1 = t4_read_reg(adap, A_SGE_DBFIFO_STATUS); | 3420 | v1 = t4_read_reg(adap, A_SGE_DBFIFO_STATUS); |
3421 | v2 = t4_read_reg(adap, SGE_DBFIFO_STATUS2); | 3421 | v2 = t4_read_reg(adap, SGE_DBFIFO_STATUS2); |
3422 | if (is_t4(adap->chip)) { | 3422 | if (is_t4(adap->params.chip)) { |
3423 | lp_count = G_LP_COUNT(v1); | 3423 | lp_count = G_LP_COUNT(v1); |
3424 | hp_count = G_HP_COUNT(v1); | 3424 | hp_count = G_HP_COUNT(v1); |
3425 | } else { | 3425 | } else { |
@@ -3588,7 +3588,7 @@ static void drain_db_fifo(struct adapter *adap, int usecs) | |||
3588 | do { | 3588 | do { |
3589 | v1 = t4_read_reg(adap, A_SGE_DBFIFO_STATUS); | 3589 | v1 = t4_read_reg(adap, A_SGE_DBFIFO_STATUS); |
3590 | v2 = t4_read_reg(adap, SGE_DBFIFO_STATUS2); | 3590 | v2 = t4_read_reg(adap, SGE_DBFIFO_STATUS2); |
3591 | if (is_t4(adap->chip)) { | 3591 | if (is_t4(adap->params.chip)) { |
3592 | lp_count = G_LP_COUNT(v1); | 3592 | lp_count = G_LP_COUNT(v1); |
3593 | hp_count = G_HP_COUNT(v1); | 3593 | hp_count = G_HP_COUNT(v1); |
3594 | } else { | 3594 | } else { |
@@ -3708,7 +3708,7 @@ static void process_db_drop(struct work_struct *work) | |||
3708 | 3708 | ||
3709 | adap = container_of(work, struct adapter, db_drop_task); | 3709 | adap = container_of(work, struct adapter, db_drop_task); |
3710 | 3710 | ||
3711 | if (is_t4(adap->chip)) { | 3711 | if (is_t4(adap->params.chip)) { |
3712 | disable_dbs(adap); | 3712 | disable_dbs(adap); |
3713 | notify_rdma_uld(adap, CXGB4_CONTROL_DB_DROP); | 3713 | notify_rdma_uld(adap, CXGB4_CONTROL_DB_DROP); |
3714 | drain_db_fifo(adap, 1); | 3714 | drain_db_fifo(adap, 1); |
@@ -3753,7 +3753,7 @@ static void process_db_drop(struct work_struct *work) | |||
3753 | 3753 | ||
3754 | void t4_db_full(struct adapter *adap) | 3754 | void t4_db_full(struct adapter *adap) |
3755 | { | 3755 | { |
3756 | if (is_t4(adap->chip)) { | 3756 | if (is_t4(adap->params.chip)) { |
3757 | t4_set_reg_field(adap, SGE_INT_ENABLE3, | 3757 | t4_set_reg_field(adap, SGE_INT_ENABLE3, |
3758 | DBFIFO_HP_INT | DBFIFO_LP_INT, 0); | 3758 | DBFIFO_HP_INT | DBFIFO_LP_INT, 0); |
3759 | queue_work(workq, &adap->db_full_task); | 3759 | queue_work(workq, &adap->db_full_task); |
@@ -3762,7 +3762,7 @@ void t4_db_full(struct adapter *adap) | |||
3762 | 3762 | ||
3763 | void t4_db_dropped(struct adapter *adap) | 3763 | void t4_db_dropped(struct adapter *adap) |
3764 | { | 3764 | { |
3765 | if (is_t4(adap->chip)) | 3765 | if (is_t4(adap->params.chip)) |
3766 | queue_work(workq, &adap->db_drop_task); | 3766 | queue_work(workq, &adap->db_drop_task); |
3767 | } | 3767 | } |
3768 | 3768 | ||
@@ -3789,7 +3789,7 @@ static void uld_attach(struct adapter *adap, unsigned int uld) | |||
3789 | lli.nchan = adap->params.nports; | 3789 | lli.nchan = adap->params.nports; |
3790 | lli.nports = adap->params.nports; | 3790 | lli.nports = adap->params.nports; |
3791 | lli.wr_cred = adap->params.ofldq_wr_cred; | 3791 | lli.wr_cred = adap->params.ofldq_wr_cred; |
3792 | lli.adapter_type = adap->params.rev; | 3792 | lli.adapter_type = adap->params.chip; |
3793 | lli.iscsi_iolen = MAXRXDATA_GET(t4_read_reg(adap, TP_PARA_REG2)); | 3793 | lli.iscsi_iolen = MAXRXDATA_GET(t4_read_reg(adap, TP_PARA_REG2)); |
3794 | lli.udb_density = 1 << QUEUESPERPAGEPF0_GET( | 3794 | lli.udb_density = 1 << QUEUESPERPAGEPF0_GET( |
3795 | t4_read_reg(adap, SGE_EGRESS_QUEUES_PER_PAGE_PF) >> | 3795 | t4_read_reg(adap, SGE_EGRESS_QUEUES_PER_PAGE_PF) >> |
@@ -4483,7 +4483,7 @@ static void setup_memwin(struct adapter *adap) | |||
4483 | u32 bar0, mem_win0_base, mem_win1_base, mem_win2_base; | 4483 | u32 bar0, mem_win0_base, mem_win1_base, mem_win2_base; |
4484 | 4484 | ||
4485 | bar0 = pci_resource_start(adap->pdev, 0); /* truncation intentional */ | 4485 | bar0 = pci_resource_start(adap->pdev, 0); /* truncation intentional */ |
4486 | if (is_t4(adap->chip)) { | 4486 | if (is_t4(adap->params.chip)) { |
4487 | mem_win0_base = bar0 + MEMWIN0_BASE; | 4487 | mem_win0_base = bar0 + MEMWIN0_BASE; |
4488 | mem_win1_base = bar0 + MEMWIN1_BASE; | 4488 | mem_win1_base = bar0 + MEMWIN1_BASE; |
4489 | mem_win2_base = bar0 + MEMWIN2_BASE; | 4489 | mem_win2_base = bar0 + MEMWIN2_BASE; |
@@ -4686,7 +4686,7 @@ static int adap_init0_config(struct adapter *adapter, int reset) | |||
4686 | * then use that. Otherwise, use the configuration file stored | 4686 | * then use that. Otherwise, use the configuration file stored |
4687 | * in the adapter flash ... | 4687 | * in the adapter flash ... |
4688 | */ | 4688 | */ |
4689 | switch (CHELSIO_CHIP_VERSION(adapter->chip)) { | 4689 | switch (CHELSIO_CHIP_VERSION(adapter->params.chip)) { |
4690 | case CHELSIO_T4: | 4690 | case CHELSIO_T4: |
4691 | fw_config_file = FW_CFNAME; | 4691 | fw_config_file = FW_CFNAME; |
4692 | break; | 4692 | break; |
@@ -5787,7 +5787,7 @@ static void print_port_info(const struct net_device *dev) | |||
5787 | 5787 | ||
5788 | netdev_info(dev, "Chelsio %s rev %d %s %sNIC PCIe x%d%s%s\n", | 5788 | netdev_info(dev, "Chelsio %s rev %d %s %sNIC PCIe x%d%s%s\n", |
5789 | adap->params.vpd.id, | 5789 | adap->params.vpd.id, |
5790 | CHELSIO_CHIP_RELEASE(adap->params.rev), buf, | 5790 | CHELSIO_CHIP_RELEASE(adap->params.chip), buf, |
5791 | is_offload(adap) ? "R" : "", adap->params.pci.width, spd, | 5791 | is_offload(adap) ? "R" : "", adap->params.pci.width, spd, |
5792 | (adap->flags & USING_MSIX) ? " MSI-X" : | 5792 | (adap->flags & USING_MSIX) ? " MSI-X" : |
5793 | (adap->flags & USING_MSI) ? " MSI" : ""); | 5793 | (adap->flags & USING_MSI) ? " MSI" : ""); |
@@ -5910,7 +5910,7 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
5910 | if (err) | 5910 | if (err) |
5911 | goto out_unmap_bar0; | 5911 | goto out_unmap_bar0; |
5912 | 5912 | ||
5913 | if (!is_t4(adapter->chip)) { | 5913 | if (!is_t4(adapter->params.chip)) { |
5914 | s_qpp = QUEUESPERPAGEPF1 * adapter->fn; | 5914 | s_qpp = QUEUESPERPAGEPF1 * adapter->fn; |
5915 | qpp = 1 << QUEUESPERPAGEPF0_GET(t4_read_reg(adapter, | 5915 | qpp = 1 << QUEUESPERPAGEPF0_GET(t4_read_reg(adapter, |
5916 | SGE_EGRESS_QUEUES_PER_PAGE_PF) >> s_qpp); | 5916 | SGE_EGRESS_QUEUES_PER_PAGE_PF) >> s_qpp); |
@@ -6064,7 +6064,7 @@ sriov: | |||
6064 | out_free_dev: | 6064 | out_free_dev: |
6065 | free_some_resources(adapter); | 6065 | free_some_resources(adapter); |
6066 | out_unmap_bar: | 6066 | out_unmap_bar: |
6067 | if (!is_t4(adapter->chip)) | 6067 | if (!is_t4(adapter->params.chip)) |
6068 | iounmap(adapter->bar2); | 6068 | iounmap(adapter->bar2); |
6069 | out_unmap_bar0: | 6069 | out_unmap_bar0: |
6070 | iounmap(adapter->regs); | 6070 | iounmap(adapter->regs); |
@@ -6116,7 +6116,7 @@ static void remove_one(struct pci_dev *pdev) | |||
6116 | 6116 | ||
6117 | free_some_resources(adapter); | 6117 | free_some_resources(adapter); |
6118 | iounmap(adapter->regs); | 6118 | iounmap(adapter->regs); |
6119 | if (!is_t4(adapter->chip)) | 6119 | if (!is_t4(adapter->params.chip)) |
6120 | iounmap(adapter->bar2); | 6120 | iounmap(adapter->bar2); |
6121 | kfree(adapter); | 6121 | kfree(adapter); |
6122 | pci_disable_pcie_error_reporting(pdev); | 6122 | pci_disable_pcie_error_reporting(pdev); |
diff --git a/drivers/net/ethernet/chelsio/cxgb4/sge.c b/drivers/net/ethernet/chelsio/cxgb4/sge.c index ac311f5f3eb9..cc380c36e1a8 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/sge.c +++ b/drivers/net/ethernet/chelsio/cxgb4/sge.c | |||
@@ -509,7 +509,7 @@ static inline void ring_fl_db(struct adapter *adap, struct sge_fl *q) | |||
509 | u32 val; | 509 | u32 val; |
510 | if (q->pend_cred >= 8) { | 510 | if (q->pend_cred >= 8) { |
511 | val = PIDX(q->pend_cred / 8); | 511 | val = PIDX(q->pend_cred / 8); |
512 | if (!is_t4(adap->chip)) | 512 | if (!is_t4(adap->params.chip)) |
513 | val |= DBTYPE(1); | 513 | val |= DBTYPE(1); |
514 | wmb(); | 514 | wmb(); |
515 | t4_write_reg(adap, MYPF_REG(SGE_PF_KDOORBELL), DBPRIO(1) | | 515 | t4_write_reg(adap, MYPF_REG(SGE_PF_KDOORBELL), DBPRIO(1) | |
@@ -847,7 +847,7 @@ static inline void ring_tx_db(struct adapter *adap, struct sge_txq *q, int n) | |||
847 | wmb(); /* write descriptors before telling HW */ | 847 | wmb(); /* write descriptors before telling HW */ |
848 | spin_lock(&q->db_lock); | 848 | spin_lock(&q->db_lock); |
849 | if (!q->db_disabled) { | 849 | if (!q->db_disabled) { |
850 | if (is_t4(adap->chip)) { | 850 | if (is_t4(adap->params.chip)) { |
851 | t4_write_reg(adap, MYPF_REG(SGE_PF_KDOORBELL), | 851 | t4_write_reg(adap, MYPF_REG(SGE_PF_KDOORBELL), |
852 | QID(q->cntxt_id) | PIDX(n)); | 852 | QID(q->cntxt_id) | PIDX(n)); |
853 | } else { | 853 | } else { |
@@ -1596,7 +1596,7 @@ static noinline int handle_trace_pkt(struct adapter *adap, | |||
1596 | return 0; | 1596 | return 0; |
1597 | } | 1597 | } |
1598 | 1598 | ||
1599 | if (is_t4(adap->chip)) | 1599 | if (is_t4(adap->params.chip)) |
1600 | __skb_pull(skb, sizeof(struct cpl_trace_pkt)); | 1600 | __skb_pull(skb, sizeof(struct cpl_trace_pkt)); |
1601 | else | 1601 | else |
1602 | __skb_pull(skb, sizeof(struct cpl_t5_trace_pkt)); | 1602 | __skb_pull(skb, sizeof(struct cpl_t5_trace_pkt)); |
@@ -1661,7 +1661,7 @@ int t4_ethrx_handler(struct sge_rspq *q, const __be64 *rsp, | |||
1661 | const struct cpl_rx_pkt *pkt; | 1661 | const struct cpl_rx_pkt *pkt; |
1662 | struct sge_eth_rxq *rxq = container_of(q, struct sge_eth_rxq, rspq); | 1662 | struct sge_eth_rxq *rxq = container_of(q, struct sge_eth_rxq, rspq); |
1663 | struct sge *s = &q->adap->sge; | 1663 | struct sge *s = &q->adap->sge; |
1664 | int cpl_trace_pkt = is_t4(q->adap->chip) ? | 1664 | int cpl_trace_pkt = is_t4(q->adap->params.chip) ? |
1665 | CPL_TRACE_PKT : CPL_TRACE_PKT_T5; | 1665 | CPL_TRACE_PKT : CPL_TRACE_PKT_T5; |
1666 | 1666 | ||
1667 | if (unlikely(*(u8 *)rsp == cpl_trace_pkt)) | 1667 | if (unlikely(*(u8 *)rsp == cpl_trace_pkt)) |
@@ -2182,7 +2182,7 @@ err: | |||
2182 | static void init_txq(struct adapter *adap, struct sge_txq *q, unsigned int id) | 2182 | static void init_txq(struct adapter *adap, struct sge_txq *q, unsigned int id) |
2183 | { | 2183 | { |
2184 | q->cntxt_id = id; | 2184 | q->cntxt_id = id; |
2185 | if (!is_t4(adap->chip)) { | 2185 | if (!is_t4(adap->params.chip)) { |
2186 | unsigned int s_qpp; | 2186 | unsigned int s_qpp; |
2187 | unsigned short udb_density; | 2187 | unsigned short udb_density; |
2188 | unsigned long qpshift; | 2188 | unsigned long qpshift; |
@@ -2641,7 +2641,7 @@ static int t4_sge_init_hard(struct adapter *adap) | |||
2641 | * Set up to drop DOORBELL writes when the DOORBELL FIFO overflows | 2641 | * Set up to drop DOORBELL writes when the DOORBELL FIFO overflows |
2642 | * and generate an interrupt when this occurs so we can recover. | 2642 | * and generate an interrupt when this occurs so we can recover. |
2643 | */ | 2643 | */ |
2644 | if (is_t4(adap->chip)) { | 2644 | if (is_t4(adap->params.chip)) { |
2645 | t4_set_reg_field(adap, A_SGE_DBFIFO_STATUS, | 2645 | t4_set_reg_field(adap, A_SGE_DBFIFO_STATUS, |
2646 | V_HP_INT_THRESH(M_HP_INT_THRESH) | | 2646 | V_HP_INT_THRESH(M_HP_INT_THRESH) | |
2647 | V_LP_INT_THRESH(M_LP_INT_THRESH), | 2647 | V_LP_INT_THRESH(M_LP_INT_THRESH), |
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c index 4cbb2f9850be..83b5e42b66a9 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c +++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | |||
@@ -296,7 +296,7 @@ int t4_mc_read(struct adapter *adap, int idx, u32 addr, __be32 *data, u64 *ecc) | |||
296 | u32 mc_bist_cmd, mc_bist_cmd_addr, mc_bist_cmd_len; | 296 | u32 mc_bist_cmd, mc_bist_cmd_addr, mc_bist_cmd_len; |
297 | u32 mc_bist_status_rdata, mc_bist_data_pattern; | 297 | u32 mc_bist_status_rdata, mc_bist_data_pattern; |
298 | 298 | ||
299 | if (is_t4(adap->chip)) { | 299 | if (is_t4(adap->params.chip)) { |
300 | mc_bist_cmd = MC_BIST_CMD; | 300 | mc_bist_cmd = MC_BIST_CMD; |
301 | mc_bist_cmd_addr = MC_BIST_CMD_ADDR; | 301 | mc_bist_cmd_addr = MC_BIST_CMD_ADDR; |
302 | mc_bist_cmd_len = MC_BIST_CMD_LEN; | 302 | mc_bist_cmd_len = MC_BIST_CMD_LEN; |
@@ -349,7 +349,7 @@ int t4_edc_read(struct adapter *adap, int idx, u32 addr, __be32 *data, u64 *ecc) | |||
349 | u32 edc_bist_cmd, edc_bist_cmd_addr, edc_bist_cmd_len; | 349 | u32 edc_bist_cmd, edc_bist_cmd_addr, edc_bist_cmd_len; |
350 | u32 edc_bist_cmd_data_pattern, edc_bist_status_rdata; | 350 | u32 edc_bist_cmd_data_pattern, edc_bist_status_rdata; |
351 | 351 | ||
352 | if (is_t4(adap->chip)) { | 352 | if (is_t4(adap->params.chip)) { |
353 | edc_bist_cmd = EDC_REG(EDC_BIST_CMD, idx); | 353 | edc_bist_cmd = EDC_REG(EDC_BIST_CMD, idx); |
354 | edc_bist_cmd_addr = EDC_REG(EDC_BIST_CMD_ADDR, idx); | 354 | edc_bist_cmd_addr = EDC_REG(EDC_BIST_CMD_ADDR, idx); |
355 | edc_bist_cmd_len = EDC_REG(EDC_BIST_CMD_LEN, idx); | 355 | edc_bist_cmd_len = EDC_REG(EDC_BIST_CMD_LEN, idx); |
@@ -402,7 +402,7 @@ int t4_edc_read(struct adapter *adap, int idx, u32 addr, __be32 *data, u64 *ecc) | |||
402 | static int t4_mem_win_rw(struct adapter *adap, u32 addr, __be32 *data, int dir) | 402 | static int t4_mem_win_rw(struct adapter *adap, u32 addr, __be32 *data, int dir) |
403 | { | 403 | { |
404 | int i; | 404 | int i; |
405 | u32 win_pf = is_t4(adap->chip) ? 0 : V_PFNUM(adap->fn); | 405 | u32 win_pf = is_t4(adap->params.chip) ? 0 : V_PFNUM(adap->fn); |
406 | 406 | ||
407 | /* | 407 | /* |
408 | * Setup offset into PCIE memory window. Address must be a | 408 | * Setup offset into PCIE memory window. Address must be a |
@@ -918,7 +918,7 @@ int t4_check_fw_version(struct adapter *adapter) | |||
918 | minor = FW_HDR_FW_VER_MINOR_GET(adapter->params.fw_vers); | 918 | minor = FW_HDR_FW_VER_MINOR_GET(adapter->params.fw_vers); |
919 | micro = FW_HDR_FW_VER_MICRO_GET(adapter->params.fw_vers); | 919 | micro = FW_HDR_FW_VER_MICRO_GET(adapter->params.fw_vers); |
920 | 920 | ||
921 | switch (CHELSIO_CHIP_VERSION(adapter->chip)) { | 921 | switch (CHELSIO_CHIP_VERSION(adapter->params.chip)) { |
922 | case CHELSIO_T4: | 922 | case CHELSIO_T4: |
923 | exp_major = FW_VERSION_MAJOR; | 923 | exp_major = FW_VERSION_MAJOR; |
924 | exp_minor = FW_VERSION_MINOR; | 924 | exp_minor = FW_VERSION_MINOR; |
@@ -931,7 +931,7 @@ int t4_check_fw_version(struct adapter *adapter) | |||
931 | break; | 931 | break; |
932 | default: | 932 | default: |
933 | dev_err(adapter->pdev_dev, "Unsupported chip type, %x\n", | 933 | dev_err(adapter->pdev_dev, "Unsupported chip type, %x\n", |
934 | adapter->chip); | 934 | adapter->params.chip); |
935 | return -EINVAL; | 935 | return -EINVAL; |
936 | } | 936 | } |
937 | 937 | ||
@@ -1368,7 +1368,7 @@ static void pcie_intr_handler(struct adapter *adapter) | |||
1368 | PCIE_CORE_UTL_PCI_EXPRESS_PORT_STATUS, | 1368 | PCIE_CORE_UTL_PCI_EXPRESS_PORT_STATUS, |
1369 | pcie_port_intr_info) + | 1369 | pcie_port_intr_info) + |
1370 | t4_handle_intr_status(adapter, PCIE_INT_CAUSE, | 1370 | t4_handle_intr_status(adapter, PCIE_INT_CAUSE, |
1371 | is_t4(adapter->chip) ? | 1371 | is_t4(adapter->params.chip) ? |
1372 | pcie_intr_info : t5_pcie_intr_info); | 1372 | pcie_intr_info : t5_pcie_intr_info); |
1373 | 1373 | ||
1374 | if (fat) | 1374 | if (fat) |
@@ -1782,7 +1782,7 @@ static void xgmac_intr_handler(struct adapter *adap, int port) | |||
1782 | { | 1782 | { |
1783 | u32 v, int_cause_reg; | 1783 | u32 v, int_cause_reg; |
1784 | 1784 | ||
1785 | if (is_t4(adap->chip)) | 1785 | if (is_t4(adap->params.chip)) |
1786 | int_cause_reg = PORT_REG(port, XGMAC_PORT_INT_CAUSE); | 1786 | int_cause_reg = PORT_REG(port, XGMAC_PORT_INT_CAUSE); |
1787 | else | 1787 | else |
1788 | int_cause_reg = T5_PORT_REG(port, MAC_PORT_INT_CAUSE); | 1788 | int_cause_reg = T5_PORT_REG(port, MAC_PORT_INT_CAUSE); |
@@ -2250,7 +2250,7 @@ void t4_get_port_stats(struct adapter *adap, int idx, struct port_stats *p) | |||
2250 | 2250 | ||
2251 | #define GET_STAT(name) \ | 2251 | #define GET_STAT(name) \ |
2252 | t4_read_reg64(adap, \ | 2252 | t4_read_reg64(adap, \ |
2253 | (is_t4(adap->chip) ? PORT_REG(idx, MPS_PORT_STAT_##name##_L) : \ | 2253 | (is_t4(adap->params.chip) ? PORT_REG(idx, MPS_PORT_STAT_##name##_L) : \ |
2254 | T5_PORT_REG(idx, MPS_PORT_STAT_##name##_L))) | 2254 | T5_PORT_REG(idx, MPS_PORT_STAT_##name##_L))) |
2255 | #define GET_STAT_COM(name) t4_read_reg64(adap, MPS_STAT_##name##_L) | 2255 | #define GET_STAT_COM(name) t4_read_reg64(adap, MPS_STAT_##name##_L) |
2256 | 2256 | ||
@@ -2332,7 +2332,7 @@ void t4_wol_magic_enable(struct adapter *adap, unsigned int port, | |||
2332 | { | 2332 | { |
2333 | u32 mag_id_reg_l, mag_id_reg_h, port_cfg_reg; | 2333 | u32 mag_id_reg_l, mag_id_reg_h, port_cfg_reg; |
2334 | 2334 | ||
2335 | if (is_t4(adap->chip)) { | 2335 | if (is_t4(adap->params.chip)) { |
2336 | mag_id_reg_l = PORT_REG(port, XGMAC_PORT_MAGIC_MACID_LO); | 2336 | mag_id_reg_l = PORT_REG(port, XGMAC_PORT_MAGIC_MACID_LO); |
2337 | mag_id_reg_h = PORT_REG(port, XGMAC_PORT_MAGIC_MACID_HI); | 2337 | mag_id_reg_h = PORT_REG(port, XGMAC_PORT_MAGIC_MACID_HI); |
2338 | port_cfg_reg = PORT_REG(port, XGMAC_PORT_CFG2); | 2338 | port_cfg_reg = PORT_REG(port, XGMAC_PORT_CFG2); |
@@ -2374,7 +2374,7 @@ int t4_wol_pat_enable(struct adapter *adap, unsigned int port, unsigned int map, | |||
2374 | int i; | 2374 | int i; |
2375 | u32 port_cfg_reg; | 2375 | u32 port_cfg_reg; |
2376 | 2376 | ||
2377 | if (is_t4(adap->chip)) | 2377 | if (is_t4(adap->params.chip)) |
2378 | port_cfg_reg = PORT_REG(port, XGMAC_PORT_CFG2); | 2378 | port_cfg_reg = PORT_REG(port, XGMAC_PORT_CFG2); |
2379 | else | 2379 | else |
2380 | port_cfg_reg = T5_PORT_REG(port, MAC_PORT_CFG2); | 2380 | port_cfg_reg = T5_PORT_REG(port, MAC_PORT_CFG2); |
@@ -2387,7 +2387,7 @@ int t4_wol_pat_enable(struct adapter *adap, unsigned int port, unsigned int map, | |||
2387 | return -EINVAL; | 2387 | return -EINVAL; |
2388 | 2388 | ||
2389 | #define EPIO_REG(name) \ | 2389 | #define EPIO_REG(name) \ |
2390 | (is_t4(adap->chip) ? PORT_REG(port, XGMAC_PORT_EPIO_##name) : \ | 2390 | (is_t4(adap->params.chip) ? PORT_REG(port, XGMAC_PORT_EPIO_##name) : \ |
2391 | T5_PORT_REG(port, MAC_PORT_EPIO_##name)) | 2391 | T5_PORT_REG(port, MAC_PORT_EPIO_##name)) |
2392 | 2392 | ||
2393 | t4_write_reg(adap, EPIO_REG(DATA1), mask0 >> 32); | 2393 | t4_write_reg(adap, EPIO_REG(DATA1), mask0 >> 32); |
@@ -2474,7 +2474,7 @@ int t4_fwaddrspace_write(struct adapter *adap, unsigned int mbox, | |||
2474 | int t4_mem_win_read_len(struct adapter *adap, u32 addr, __be32 *data, int len) | 2474 | int t4_mem_win_read_len(struct adapter *adap, u32 addr, __be32 *data, int len) |
2475 | { | 2475 | { |
2476 | int i, off; | 2476 | int i, off; |
2477 | u32 win_pf = is_t4(adap->chip) ? 0 : V_PFNUM(adap->fn); | 2477 | u32 win_pf = is_t4(adap->params.chip) ? 0 : V_PFNUM(adap->fn); |
2478 | 2478 | ||
2479 | /* Align on a 2KB boundary. | 2479 | /* Align on a 2KB boundary. |
2480 | */ | 2480 | */ |
@@ -3306,7 +3306,7 @@ int t4_alloc_mac_filt(struct adapter *adap, unsigned int mbox, | |||
3306 | int i, ret; | 3306 | int i, ret; |
3307 | struct fw_vi_mac_cmd c; | 3307 | struct fw_vi_mac_cmd c; |
3308 | struct fw_vi_mac_exact *p; | 3308 | struct fw_vi_mac_exact *p; |
3309 | unsigned int max_naddr = is_t4(adap->chip) ? | 3309 | unsigned int max_naddr = is_t4(adap->params.chip) ? |
3310 | NUM_MPS_CLS_SRAM_L_INSTANCES : | 3310 | NUM_MPS_CLS_SRAM_L_INSTANCES : |
3311 | NUM_MPS_T5_CLS_SRAM_L_INSTANCES; | 3311 | NUM_MPS_T5_CLS_SRAM_L_INSTANCES; |
3312 | 3312 | ||
@@ -3368,7 +3368,7 @@ int t4_change_mac(struct adapter *adap, unsigned int mbox, unsigned int viid, | |||
3368 | int ret, mode; | 3368 | int ret, mode; |
3369 | struct fw_vi_mac_cmd c; | 3369 | struct fw_vi_mac_cmd c; |
3370 | struct fw_vi_mac_exact *p = c.u.exact; | 3370 | struct fw_vi_mac_exact *p = c.u.exact; |
3371 | unsigned int max_mac_addr = is_t4(adap->chip) ? | 3371 | unsigned int max_mac_addr = is_t4(adap->params.chip) ? |
3372 | NUM_MPS_CLS_SRAM_L_INSTANCES : | 3372 | NUM_MPS_CLS_SRAM_L_INSTANCES : |
3373 | NUM_MPS_T5_CLS_SRAM_L_INSTANCES; | 3373 | NUM_MPS_T5_CLS_SRAM_L_INSTANCES; |
3374 | 3374 | ||
@@ -3699,13 +3699,14 @@ int t4_prep_adapter(struct adapter *adapter) | |||
3699 | { | 3699 | { |
3700 | int ret, ver; | 3700 | int ret, ver; |
3701 | uint16_t device_id; | 3701 | uint16_t device_id; |
3702 | u32 pl_rev; | ||
3702 | 3703 | ||
3703 | ret = t4_wait_dev_ready(adapter); | 3704 | ret = t4_wait_dev_ready(adapter); |
3704 | if (ret < 0) | 3705 | if (ret < 0) |
3705 | return ret; | 3706 | return ret; |
3706 | 3707 | ||
3707 | get_pci_mode(adapter, &adapter->params.pci); | 3708 | get_pci_mode(adapter, &adapter->params.pci); |
3708 | adapter->params.rev = t4_read_reg(adapter, PL_REV); | 3709 | pl_rev = G_REV(t4_read_reg(adapter, PL_REV)); |
3709 | 3710 | ||
3710 | ret = get_flash_params(adapter); | 3711 | ret = get_flash_params(adapter); |
3711 | if (ret < 0) { | 3712 | if (ret < 0) { |
@@ -3717,14 +3718,13 @@ int t4_prep_adapter(struct adapter *adapter) | |||
3717 | */ | 3718 | */ |
3718 | pci_read_config_word(adapter->pdev, PCI_DEVICE_ID, &device_id); | 3719 | pci_read_config_word(adapter->pdev, PCI_DEVICE_ID, &device_id); |
3719 | ver = device_id >> 12; | 3720 | ver = device_id >> 12; |
3721 | adapter->params.chip = 0; | ||
3720 | switch (ver) { | 3722 | switch (ver) { |
3721 | case CHELSIO_T4: | 3723 | case CHELSIO_T4: |
3722 | adapter->chip = CHELSIO_CHIP_CODE(CHELSIO_T4, | 3724 | adapter->params.chip |= CHELSIO_CHIP_CODE(CHELSIO_T4, pl_rev); |
3723 | adapter->params.rev); | ||
3724 | break; | 3725 | break; |
3725 | case CHELSIO_T5: | 3726 | case CHELSIO_T5: |
3726 | adapter->chip = CHELSIO_CHIP_CODE(CHELSIO_T5, | 3727 | adapter->params.chip |= CHELSIO_CHIP_CODE(CHELSIO_T5, pl_rev); |
3727 | adapter->params.rev); | ||
3728 | break; | 3728 | break; |
3729 | default: | 3729 | default: |
3730 | dev_err(adapter->pdev_dev, "Device %d is not supported\n", | 3730 | dev_err(adapter->pdev_dev, "Device %d is not supported\n", |
@@ -3732,9 +3732,6 @@ int t4_prep_adapter(struct adapter *adapter) | |||
3732 | return -EINVAL; | 3732 | return -EINVAL; |
3733 | } | 3733 | } |
3734 | 3734 | ||
3735 | /* Reassign the updated revision field */ | ||
3736 | adapter->params.rev = adapter->chip; | ||
3737 | |||
3738 | init_cong_ctrl(adapter->params.a_wnd, adapter->params.b_wnd); | 3735 | init_cong_ctrl(adapter->params.a_wnd, adapter->params.b_wnd); |
3739 | 3736 | ||
3740 | /* | 3737 | /* |
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_regs.h b/drivers/net/ethernet/chelsio/cxgb4/t4_regs.h index ef146c0ba481..a7d81899a0fc 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/t4_regs.h +++ b/drivers/net/ethernet/chelsio/cxgb4/t4_regs.h | |||
@@ -1092,6 +1092,11 @@ | |||
1092 | 1092 | ||
1093 | #define PL_REV 0x1943c | 1093 | #define PL_REV 0x1943c |
1094 | 1094 | ||
1095 | #define S_REV 0 | ||
1096 | #define M_REV 0xfU | ||
1097 | #define V_REV(x) ((x) << S_REV) | ||
1098 | #define G_REV(x) (((x) >> S_REV) & M_REV) | ||
1099 | |||
1095 | #define LE_DB_CONFIG 0x19c04 | 1100 | #define LE_DB_CONFIG 0x19c04 |
1096 | #define HASHEN 0x00100000U | 1101 | #define HASHEN 0x00100000U |
1097 | 1102 | ||