Re: [PATCH 11/21] net: thunderx: Add support for 16 LMACs of 83xx

2016-08-10 Thread kbuild test robot
Hi Sunil,

[auto build test ERROR on net-next/master]
[also build test ERROR on v4.8-rc1 next-20160809]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/sunil-kovvuri-gmail-com/net-thunderx-Support-for-newer-chips-and-miscellaneous-patches/20160811-051837
config: x86_64-allmodconfig (attached as .config)
compiler: gcc-6 (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

Note: the 
linux-review/sunil-kovvuri-gmail-com/net-thunderx-Support-for-newer-chips-and-miscellaneous-patches/20160811-051837
 HEAD 5dcb590bc5f427045688ce0ace2e3d39d22e979f builds fine.
  It only hurts bisectibility.

All errors (new ones prefixed by >>):

   drivers/net/ethernet/cavium/thunder/nic_main.c: In function 
'nic_mbx_send_ready':
>> drivers/net/ethernet/cavium/thunder/nic_main.c:177:11: error: 'MAX_LMAC' 
>> undeclared (first use in this function)
 if (vf < MAX_LMAC) {
  ^~~~
   drivers/net/ethernet/cavium/thunder/nic_main.c:177:11: note: each undeclared 
identifier is reported only once for each function it appears in

vim +/MAX_LMAC +177 drivers/net/ethernet/cavium/thunder/nic_main.c

4863dea3 Sunil Goutham 2015-05-26  171  
4863dea3 Sunil Goutham 2015-05-26  172  mbx.nic_cfg.msg = 
NIC_MBOX_MSG_READY;
4863dea3 Sunil Goutham 2015-05-26  173  mbx.nic_cfg.vf_id = vf;
4863dea3 Sunil Goutham 2015-05-26  174  
4863dea3 Sunil Goutham 2015-05-26  175  mbx.nic_cfg.tns_mode = 
NIC_TNS_BYPASS_MODE;
4863dea3 Sunil Goutham 2015-05-26  176  
92dc8769 Sunil Goutham 2015-08-30 @177  if (vf < MAX_LMAC) {
4863dea3 Sunil Goutham 2015-05-26  178  bgx_idx = 
NIC_GET_BGX_FROM_VF_LMAC_MAP(nic->vf_lmac_map[vf]);
4863dea3 Sunil Goutham 2015-05-26  179  lmac = 
NIC_GET_LMAC_FROM_VF_LMAC_MAP(nic->vf_lmac_map[vf]);
4863dea3 Sunil Goutham 2015-05-26  180  

:: The code at line 177 was first introduced by commit
:: 92dc87697e6a71675a9e9eec04ebecd8cf4837a3 net: thunderx: Support for upto 
96 queues for a VF

:: TO: Sunil Goutham 
:: CC: David S. Miller 

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


[PATCH 11/21] net: thunderx: Add support for 16 LMACs of 83xx

2016-08-10 Thread sunil . kovvuri
From: Sunil Goutham 

83xx will have 4 BGX blocks i.e 16 LMACs, to avoid changing
the same with every platform, nicpf struct elements which
track LMAC related info are now allocated runtime based
on platform's max possible BGX count.

Also fixed configuring min packet size for all LMAC's
supported on a platform.

Signed-off-by: Sunil Goutham 
---
 drivers/net/ethernet/cavium/thunder/nic_main.c| 73 ++-
 drivers/net/ethernet/cavium/thunder/thunder_bgx.h |  2 -
 2 files changed, 59 insertions(+), 16 deletions(-)

diff --git a/drivers/net/ethernet/cavium/thunder/nic_main.c 
b/drivers/net/ethernet/cavium/thunder/nic_main.c
index 91c575d..8ed8ecd 100644
--- a/drivers/net/ethernet/cavium/thunder/nic_main.c
+++ b/drivers/net/ethernet/cavium/thunder/nic_main.c
@@ -53,12 +53,12 @@ struct nicpf {
 #defineNIC_SET_VF_LMAC_MAP(bgx, lmac)  (((bgx & 0xF) << 4) | (lmac & 
0xF))
 #defineNIC_GET_BGX_FROM_VF_LMAC_MAP(map)   ((map >> 4) & 0xF)
 #defineNIC_GET_LMAC_FROM_VF_LMAC_MAP(map)  (map & 0xF)
-   u8  vf_lmac_map[MAX_LMAC];
+   u8  *vf_lmac_map;
struct delayed_work dwork;
struct workqueue_struct *check_link;
-   u8  link[MAX_LMAC];
-   u8  duplex[MAX_LMAC];
-   u32 speed[MAX_LMAC];
+   u8  *link;
+   u8  *duplex;
+   u32 *speed;
u16 cpi_base[MAX_NUM_VFS_SUPPORTED];
u16 rssi_base[MAX_NUM_VFS_SUPPORTED];
boolmbx_lock[MAX_NUM_VFS_SUPPORTED];
@@ -185,7 +185,7 @@ static void nic_mbx_send_ready(struct nicpf *nic, int vf)
mbx.nic_cfg.sqs_mode = (vf >= nic->num_vf_en) ? true : false;
mbx.nic_cfg.node_id = nic->node;
 
-   mbx.nic_cfg.loopback_supported = vf < MAX_LMAC;
+   mbx.nic_cfg.loopback_supported = vf < nic->num_vf_en;
 
nic_send_msg_to_vf(nic, vf, );
 }
@@ -278,14 +278,22 @@ static int nic_update_hw_frs(struct nicpf *nic, int 
new_frs, int vf)
 /* Set minimum transmit packet size */
 static void nic_set_tx_pkt_pad(struct nicpf *nic, int size)
 {
-   int lmac;
+   int lmac, max_lmac;
+   u16 sdevid;
u64 lmac_cfg;
 
/* Max value that can be set is 60 */
if (size > 60)
size = 60;
 
-   for (lmac = 0; lmac < (MAX_BGX_PER_CN88XX * MAX_LMAC_PER_BGX); lmac++) {
+   pci_read_config_word(nic->pdev, PCI_SUBSYSTEM_ID, );
+   /* 81xx's RGX has only one LMAC */
+   if (sdevid == PCI_SUBSYS_DEVID_81XX_NIC_PF)
+   max_lmac = ((nic->hw->bgx_cnt - 1) * MAX_LMAC_PER_BGX) + 1;
+   else
+   max_lmac = nic->hw->bgx_cnt * MAX_LMAC_PER_BGX;
+
+   for (lmac = 0; lmac < max_lmac; lmac++) {
lmac_cfg = nic_reg_read(nic, NIC_PF_LMAC_0_7_CFG | (lmac << 3));
lmac_cfg &= ~(0xF << 2);
lmac_cfg |= ((size / 4) << 2);
@@ -336,8 +344,17 @@ static void nic_set_lmac_vf_mapping(struct nicpf *nic)
}
 }
 
-static void nic_get_hw_info(struct nicpf *nic)
+static void nic_free_lmacmem(struct nicpf *nic)
 {
+   kfree(nic->vf_lmac_map);
+   kfree(nic->link);
+   kfree(nic->duplex);
+   kfree(nic->speed);
+}
+
+static int nic_get_hw_info(struct nicpf *nic)
+{
+   u8 max_lmac;
u16 sdevid;
struct hw_info *hw = nic->hw;
 
@@ -385,18 +402,40 @@ static void nic_get_hw_info(struct nicpf *nic)
break;
}
hw->tl4_cnt = MAX_QUEUES_PER_QSET * pci_sriov_get_totalvfs(nic->pdev);
+
+   /* Allocate memory for LMAC tracking elements */
+   max_lmac = hw->bgx_cnt * MAX_LMAC_PER_BGX;
+   nic->vf_lmac_map = kmalloc_array(max_lmac, sizeof(u8), GFP_KERNEL);
+   if (!nic->vf_lmac_map)
+   goto error;
+   nic->link = kmalloc_array(max_lmac, sizeof(u8), GFP_KERNEL);
+   if (!nic->link)
+   goto error;
+   nic->duplex = kmalloc_array(max_lmac, sizeof(u8), GFP_KERNEL);
+   if (!nic->duplex)
+   goto error;
+   nic->speed = kmalloc_array(max_lmac, sizeof(u32), GFP_KERNEL);
+   if (!nic->speed)
+   goto error;
+   return 0;
+
+error:
+   nic_free_lmacmem(nic);
+   return -ENOMEM;
 }
 
 #define BGX0_BLOCK 8
 #define BGX1_BLOCK 9
 
-static void nic_init_hw(struct nicpf *nic)
+static int nic_init_hw(struct nicpf *nic)
 {
-   int i;
+   int i, err;
u64 cqm_cfg;
 
/* Get HW capability info */
-   nic_get_hw_info(nic);
+   err = nic_get_hw_info(nic);
+   if (err)
+   return err;
 
/* Enable NIC HW block */
nic_reg_write(nic, NIC_PF_CFG, 0x3);
@@ -442,6 +481,8 @@ static void nic_init_hw(struct nicpf *nic)
cqm_cfg = nic_reg_read(nic, NIC_PF_CQM_CFG);
if (cqm_cfg < NICPF_CQM_MIN_DROP_LEVEL)