@@ -14653,6 +14653,90 @@ static int bnx2x_drv_ctl(struct net_device *dev, struct drv_ctl_info *ctl)
1465314653 rc = - EINVAL ;
1465414654 }
1465514655
14656+ /* For storage-only interfaces, change driver state */
14657+ if (IS_MF_SD_STORAGE_PERSONALITY_ONLY (bp )) {
14658+ switch (ctl -> drv_state ) {
14659+ case DRV_NOP :
14660+ break ;
14661+ case DRV_ACTIVE :
14662+ bnx2x_set_os_driver_state (bp ,
14663+ OS_DRIVER_STATE_ACTIVE );
14664+ break ;
14665+ case DRV_INACTIVE :
14666+ bnx2x_set_os_driver_state (bp ,
14667+ OS_DRIVER_STATE_DISABLED );
14668+ break ;
14669+ case DRV_UNLOADED :
14670+ bnx2x_set_os_driver_state (bp ,
14671+ OS_DRIVER_STATE_NOT_LOADED );
14672+ break ;
14673+ default :
14674+ BNX2X_ERR ("Unknown cnic driver state: %d\n" , ctl -> drv_state );
14675+ }
14676+ }
14677+
14678+ return rc ;
14679+ }
14680+
14681+ static int bnx2x_get_fc_npiv (struct net_device * dev ,
14682+ struct cnic_fc_npiv_tbl * cnic_tbl )
14683+ {
14684+ struct bnx2x * bp = netdev_priv (dev );
14685+ struct bdn_fc_npiv_tbl * tbl = NULL ;
14686+ u32 offset , entries ;
14687+ int rc = - EINVAL ;
14688+ int i ;
14689+
14690+ if (!SHMEM2_HAS (bp , fc_npiv_nvram_tbl_addr [0 ]))
14691+ goto out ;
14692+
14693+ DP (BNX2X_MSG_MCP , "About to read the FC-NPIV table\n" );
14694+
14695+ tbl = kmalloc (sizeof (* tbl ), GFP_KERNEL );
14696+ if (!tbl ) {
14697+ BNX2X_ERR ("Failed to allocate fc_npiv table\n" );
14698+ goto out ;
14699+ }
14700+
14701+ offset = SHMEM2_RD (bp , fc_npiv_nvram_tbl_addr [BP_PORT (bp )]);
14702+ DP (BNX2X_MSG_MCP , "Offset of FC-NPIV in NVRAM: %08x\n" , offset );
14703+
14704+ /* Read the table contents from nvram */
14705+ if (bnx2x_nvram_read (bp , offset , (u8 * )tbl , sizeof (* tbl ))) {
14706+ BNX2X_ERR ("Failed to read FC-NPIV table\n" );
14707+ goto out ;
14708+ }
14709+
14710+ /* Since bnx2x_nvram_read() returns data in be32, we need to convert
14711+ * the number of entries back to cpu endianness.
14712+ */
14713+ entries = tbl -> fc_npiv_cfg .num_of_npiv ;
14714+ entries = (__force u32 )be32_to_cpu ((__force __be32 )entries );
14715+ tbl -> fc_npiv_cfg .num_of_npiv = entries ;
14716+
14717+ if (!tbl -> fc_npiv_cfg .num_of_npiv ) {
14718+ DP (BNX2X_MSG_MCP ,
14719+ "No FC-NPIV table [valid, simply not present]\n" );
14720+ goto out ;
14721+ } else if (tbl -> fc_npiv_cfg .num_of_npiv > MAX_NUMBER_NPIV ) {
14722+ BNX2X_ERR ("FC-NPIV table with bad length 0x%08x\n" ,
14723+ tbl -> fc_npiv_cfg .num_of_npiv );
14724+ goto out ;
14725+ } else {
14726+ DP (BNX2X_MSG_MCP , "Read 0x%08x entries from NVRAM\n" ,
14727+ tbl -> fc_npiv_cfg .num_of_npiv );
14728+ }
14729+
14730+ /* Copy the data into cnic-provided struct */
14731+ cnic_tbl -> count = tbl -> fc_npiv_cfg .num_of_npiv ;
14732+ for (i = 0 ; i < cnic_tbl -> count ; i ++ ) {
14733+ memcpy (cnic_tbl -> wwpn [i ], tbl -> settings [i ].npiv_wwpn , 8 );
14734+ memcpy (cnic_tbl -> wwnn [i ], tbl -> settings [i ].npiv_wwnn , 8 );
14735+ }
14736+
14737+ rc = 0 ;
14738+ out :
14739+ kfree (tbl );
1465614740 return rc ;
1465714741}
1465814742
@@ -14798,6 +14882,7 @@ static struct cnic_eth_dev *bnx2x_cnic_probe(struct net_device *dev)
1479814882 cp -> starting_cid = bnx2x_cid_ilt_lines (bp ) * ILT_PAGE_CIDS ;
1479914883 cp -> drv_submit_kwqes_16 = bnx2x_cnic_sp_queue ;
1480014884 cp -> drv_ctl = bnx2x_drv_ctl ;
14885+ cp -> drv_get_fc_npiv_tbl = bnx2x_get_fc_npiv ;
1480114886 cp -> drv_register_cnic = bnx2x_register_cnic ;
1480214887 cp -> drv_unregister_cnic = bnx2x_unregister_cnic ;
1480314888 cp -> fcoe_init_cid = BNX2X_FCOE_ETH_CID (bp );
0 commit comments