aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSunil Goutham <sgoutham@cavium.com>2015-12-02 05:06:17 -0500
committerDavid S. Miller <davem@davemloft.net>2015-12-02 15:58:50 -0500
commitbc69fdfc6c13b7350be9bcb48328d8f231ed98bb (patch)
tree96c41f3f33164d7591aafb330b9cb2001786ad60
parent0b72a9a1060e7547e71e7f600849a2d3006bf63a (diff)
net: thunderx: Enable BGX LMAC's RX/TX only after VF is up
Enable or disable BGX LMAC's RX/TX based on corresponding VF's status. If otherwise, when multiple LMAC's physical link is up then packets from all LMAC's whose corresponding VF is not yet initialized will get forwarded to VF0. This is due to VNIC's default configuration where CPI, RSSI e.t.c point to VF0/QSET0/RQ0. This patch will prevent multiple copies of packets on VF0. Signed-off-by: Sunil Goutham <sgoutham@cavium.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/cavium/thunder/nic_main.c20
-rw-r--r--drivers/net/ethernet/cavium/thunder/thunder_bgx.c20
-rw-r--r--drivers/net/ethernet/cavium/thunder/thunder_bgx.h1
3 files changed, 38 insertions, 3 deletions
diff --git a/drivers/net/ethernet/cavium/thunder/nic_main.c b/drivers/net/ethernet/cavium/thunder/nic_main.c
index cfc24a1daff1..4b7fd63ae57c 100644
--- a/drivers/net/ethernet/cavium/thunder/nic_main.c
+++ b/drivers/net/ethernet/cavium/thunder/nic_main.c
@@ -37,6 +37,7 @@ struct nicpf {
37#define NIC_GET_BGX_FROM_VF_LMAC_MAP(map) ((map >> 4) & 0xF) 37#define NIC_GET_BGX_FROM_VF_LMAC_MAP(map) ((map >> 4) & 0xF)
38#define NIC_GET_LMAC_FROM_VF_LMAC_MAP(map) (map & 0xF) 38#define NIC_GET_LMAC_FROM_VF_LMAC_MAP(map) (map & 0xF)
39 u8 vf_lmac_map[MAX_LMAC]; 39 u8 vf_lmac_map[MAX_LMAC];
40 u8 lmac_cnt;
40 struct delayed_work dwork; 41 struct delayed_work dwork;
41 struct workqueue_struct *check_link; 42 struct workqueue_struct *check_link;
42 u8 link[MAX_LMAC]; 43 u8 link[MAX_LMAC];
@@ -279,6 +280,7 @@ static void nic_set_lmac_vf_mapping(struct nicpf *nic)
279 u64 lmac_credit; 280 u64 lmac_credit;
280 281
281 nic->num_vf_en = 0; 282 nic->num_vf_en = 0;
283 nic->lmac_cnt = 0;
282 284
283 for (bgx = 0; bgx < NIC_MAX_BGX; bgx++) { 285 for (bgx = 0; bgx < NIC_MAX_BGX; bgx++) {
284 if (!(bgx_map & (1 << bgx))) 286 if (!(bgx_map & (1 << bgx)))
@@ -288,6 +290,7 @@ static void nic_set_lmac_vf_mapping(struct nicpf *nic)
288 nic->vf_lmac_map[next_bgx_lmac++] = 290 nic->vf_lmac_map[next_bgx_lmac++] =
289 NIC_SET_VF_LMAC_MAP(bgx, lmac); 291 NIC_SET_VF_LMAC_MAP(bgx, lmac);
290 nic->num_vf_en += lmac_cnt; 292 nic->num_vf_en += lmac_cnt;
293 nic->lmac_cnt += lmac_cnt;
291 294
292 /* Program LMAC credits */ 295 /* Program LMAC credits */
293 lmac_credit = (1ull << 1); /* channel credit enable */ 296 lmac_credit = (1ull << 1); /* channel credit enable */
@@ -715,6 +718,13 @@ static void nic_handle_mbx_intr(struct nicpf *nic, int vf)
715 case NIC_MBOX_MSG_CFG_DONE: 718 case NIC_MBOX_MSG_CFG_DONE:
716 /* Last message of VF config msg sequence */ 719 /* Last message of VF config msg sequence */
717 nic->vf_enabled[vf] = true; 720 nic->vf_enabled[vf] = true;
721 if (vf >= nic->lmac_cnt)
722 goto unlock;
723
724 bgx = NIC_GET_BGX_FROM_VF_LMAC_MAP(nic->vf_lmac_map[vf]);
725 lmac = NIC_GET_LMAC_FROM_VF_LMAC_MAP(nic->vf_lmac_map[vf]);
726
727 bgx_lmac_rx_tx_enable(nic->node, bgx, lmac, true);
718 goto unlock; 728 goto unlock;
719 case NIC_MBOX_MSG_SHUTDOWN: 729 case NIC_MBOX_MSG_SHUTDOWN:
720 /* First msg in VF teardown sequence */ 730 /* First msg in VF teardown sequence */
@@ -722,6 +732,14 @@ static void nic_handle_mbx_intr(struct nicpf *nic, int vf)
722 if (vf >= nic->num_vf_en) 732 if (vf >= nic->num_vf_en)
723 nic->sqs_used[vf - nic->num_vf_en] = false; 733 nic->sqs_used[vf - nic->num_vf_en] = false;
724 nic->pqs_vf[vf] = 0; 734 nic->pqs_vf[vf] = 0;
735
736 if (vf >= nic->lmac_cnt)
737 break;
738
739 bgx = NIC_GET_BGX_FROM_VF_LMAC_MAP(nic->vf_lmac_map[vf]);
740 lmac = NIC_GET_LMAC_FROM_VF_LMAC_MAP(nic->vf_lmac_map[vf]);
741
742 bgx_lmac_rx_tx_enable(nic->node, bgx, lmac, false);
725 break; 743 break;
726 case NIC_MBOX_MSG_ALLOC_SQS: 744 case NIC_MBOX_MSG_ALLOC_SQS:
727 nic_alloc_sqs(nic, &mbx.sqs_alloc); 745 nic_alloc_sqs(nic, &mbx.sqs_alloc);
@@ -940,7 +958,7 @@ static void nic_poll_for_link(struct work_struct *work)
940 958
941 mbx.link_status.msg = NIC_MBOX_MSG_BGX_LINK_CHANGE; 959 mbx.link_status.msg = NIC_MBOX_MSG_BGX_LINK_CHANGE;
942 960
943 for (vf = 0; vf < nic->num_vf_en; vf++) { 961 for (vf = 0; vf < nic->lmac_cnt; vf++) {
944 /* Poll only if VF is UP */ 962 /* Poll only if VF is UP */
945 if (!nic->vf_enabled[vf]) 963 if (!nic->vf_enabled[vf])
946 continue; 964 continue;
diff --git a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
index d77e41a459b9..9df26c2263bc 100644
--- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
+++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
@@ -186,6 +186,23 @@ void bgx_set_lmac_mac(int node, int bgx_idx, int lmacid, const u8 *mac)
186} 186}
187EXPORT_SYMBOL(bgx_set_lmac_mac); 187EXPORT_SYMBOL(bgx_set_lmac_mac);
188 188
189void bgx_lmac_rx_tx_enable(int node, int bgx_idx, int lmacid, bool enable)
190{
191 struct bgx *bgx = bgx_vnic[(node * MAX_BGX_PER_CN88XX) + bgx_idx];
192 u64 cfg;
193
194 if (!bgx)
195 return;
196
197 cfg = bgx_reg_read(bgx, lmacid, BGX_CMRX_CFG);
198 if (enable)
199 cfg |= CMR_PKT_RX_EN | CMR_PKT_TX_EN;
200 else
201 cfg &= ~(CMR_PKT_RX_EN | CMR_PKT_TX_EN);
202 bgx_reg_write(bgx, lmacid, BGX_CMRX_CFG, cfg);
203}
204EXPORT_SYMBOL(bgx_lmac_rx_tx_enable);
205
189static void bgx_sgmii_change_link_state(struct lmac *lmac) 206static void bgx_sgmii_change_link_state(struct lmac *lmac)
190{ 207{
191 struct bgx *bgx = lmac->bgx; 208 struct bgx *bgx = lmac->bgx;
@@ -656,8 +673,7 @@ static int bgx_lmac_enable(struct bgx *bgx, u8 lmacid)
656 } 673 }
657 674
658 /* Enable lmac */ 675 /* Enable lmac */
659 bgx_reg_modify(bgx, lmacid, BGX_CMRX_CFG, 676 bgx_reg_modify(bgx, lmacid, BGX_CMRX_CFG, CMR_EN);
660 CMR_EN | CMR_PKT_RX_EN | CMR_PKT_TX_EN);
661 677
662 /* Restore default cfg, incase low level firmware changed it */ 678 /* Restore default cfg, incase low level firmware changed it */
663 bgx_reg_write(bgx, lmacid, BGX_CMRX_RX_DMAC_CTL, 0x03); 679 bgx_reg_write(bgx, lmacid, BGX_CMRX_RX_DMAC_CTL, 0x03);
diff --git a/drivers/net/ethernet/cavium/thunder/thunder_bgx.h b/drivers/net/ethernet/cavium/thunder/thunder_bgx.h
index 89a02fa26f79..149e179363a1 100644
--- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.h
+++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.h
@@ -183,6 +183,7 @@ enum MCAST_MODE {
183#define CAM_ACCEPT 1 183#define CAM_ACCEPT 1
184 184
185void octeon_mdiobus_force_mod_depencency(void); 185void octeon_mdiobus_force_mod_depencency(void);
186void bgx_lmac_rx_tx_enable(int node, int bgx_idx, int lmacid, bool enable);
186void bgx_add_dmac_addr(u64 dmac, int node, int bgx_idx, int lmac); 187void bgx_add_dmac_addr(u64 dmac, int node, int bgx_idx, int lmac);
187unsigned bgx_get_map(int node); 188unsigned bgx_get_map(int node);
188int bgx_get_lmac_count(int node, int bgx); 189int bgx_get_lmac_count(int node, int bgx);