@@ -5240,23 +5240,19 @@ static void free_some_resources(struct adapter *adapter)
52405240 NETIF_F_IPV6_CSUM | NETIF_F_HIGHDMA)
52415241#define SEGMENT_SIZE 128
52425242
5243- static int get_chip_type (struct pci_dev * pdev , u32 pl_rev )
5243+ static int t4_get_chip_type (struct adapter * adap , int ver )
52445244{
5245- u16 device_id ;
5246-
5247- /* Retrieve adapter's device ID */
5248- pci_read_config_word (pdev , PCI_DEVICE_ID , & device_id );
5245+ u32 pl_rev = REV_G (t4_read_reg (adap , PL_REV_A ));
52495246
5250- switch (device_id >> 12 ) {
5247+ switch (ver ) {
52515248 case CHELSIO_T4 :
52525249 return CHELSIO_CHIP_CODE (CHELSIO_T4 , pl_rev );
52535250 case CHELSIO_T5 :
52545251 return CHELSIO_CHIP_CODE (CHELSIO_T5 , pl_rev );
52555252 case CHELSIO_T6 :
52565253 return CHELSIO_CHIP_CODE (CHELSIO_T6 , pl_rev );
52575254 default :
5258- dev_err (& pdev -> dev , "Device %d is not supported\n" ,
5259- device_id );
5255+ break ;
52605256 }
52615257 return - EINVAL ;
52625258}
@@ -5426,15 +5422,18 @@ static int cxgb4_iov_configure(struct pci_dev *pdev, int num_vfs)
54265422
54275423static int init_one (struct pci_dev * pdev , const struct pci_device_id * ent )
54285424{
5429- int func , i , err , s_qpp , qpp , num_seg ;
5425+ struct net_device * netdev ;
5426+ struct adapter * adapter ;
5427+ static int adap_idx = 1 ;
5428+ int s_qpp , qpp , num_seg ;
54305429 struct port_info * pi ;
54315430 bool highdma = false;
5432- struct adapter * adapter = NULL ;
5433- struct net_device * netdev ;
5434- void __iomem * regs ;
5435- u32 whoami , pl_rev ;
54365431 enum chip_type chip ;
5437- static int adap_idx = 1 ;
5432+ void __iomem * regs ;
5433+ int func , chip_ver ;
5434+ u16 device_id ;
5435+ int i , err ;
5436+ u32 whoami ;
54385437
54395438 printk_once (KERN_INFO "%s - version %s\n" , DRV_DESC , DRV_VERSION );
54405439
@@ -5470,11 +5469,17 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
54705469 goto out_free_adapter ;
54715470
54725471 /* We control everything through one PF */
5473- whoami = readl (regs + PL_WHOAMI_A );
5474- pl_rev = REV_G (readl (regs + PL_REV_A ));
5475- chip = get_chip_type (pdev , pl_rev );
5476- func = CHELSIO_CHIP_VERSION (chip ) <= CHELSIO_T5 ?
5477- SOURCEPF_G (whoami ) : T6_SOURCEPF_G (whoami );
5472+ whoami = t4_read_reg (adapter , PL_WHOAMI_A );
5473+ pci_read_config_word (pdev , PCI_DEVICE_ID , & device_id );
5474+ chip = t4_get_chip_type (adapter , CHELSIO_PCI_ID_VER (device_id ));
5475+ if (chip < 0 ) {
5476+ dev_err (& pdev -> dev , "Device %d is not supported\n" , device_id );
5477+ err = chip ;
5478+ goto out_free_adapter ;
5479+ }
5480+ chip_ver = CHELSIO_CHIP_VERSION (chip );
5481+ func = chip_ver <= CHELSIO_T5 ?
5482+ SOURCEPF_G (whoami ) : T6_SOURCEPF_G (whoami );
54785483
54795484 adapter -> pdev = pdev ;
54805485 adapter -> pdev_dev = & pdev -> dev ;
@@ -5640,7 +5645,7 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
56405645 NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX |
56415646 NETIF_F_HW_TC ;
56425647
5643- if (CHELSIO_CHIP_VERSION ( chip ) > CHELSIO_T5 ) {
5648+ if (chip_ver > CHELSIO_T5 ) {
56445649 netdev -> hw_enc_features |= NETIF_F_IP_CSUM |
56455650 NETIF_F_IPV6_CSUM |
56465651 NETIF_F_RXCSUM |
@@ -5720,7 +5725,7 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
57205725 dev_warn (& pdev -> dev , "could not allocate MPS Encap entries, continuing\n" );
57215726
57225727#if IS_ENABLED (CONFIG_IPV6 )
5723- if (( CHELSIO_CHIP_VERSION ( adapter -> params . chip ) <= CHELSIO_T5 ) &&
5728+ if (chip_ver <= CHELSIO_T5 &&
57245729 (!(t4_read_reg (adapter , LE_DB_CONFIG_A ) & ASLIPCOMPEN_F ))) {
57255730 /* CLIP functionality is not present in hardware,
57265731 * hence disable all offload features
0 commit comments