Commit bc69fdfc authored by Sunil Goutham's avatar Sunil Goutham Committed by David S. Miller

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: default avatarSunil Goutham <sgoutham@cavium.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0b72a9a1
...@@ -37,6 +37,7 @@ struct nicpf { ...@@ -37,6 +37,7 @@ struct nicpf {
#define NIC_GET_BGX_FROM_VF_LMAC_MAP(map) ((map >> 4) & 0xF) #define NIC_GET_BGX_FROM_VF_LMAC_MAP(map) ((map >> 4) & 0xF)
#define NIC_GET_LMAC_FROM_VF_LMAC_MAP(map) (map & 0xF) #define NIC_GET_LMAC_FROM_VF_LMAC_MAP(map) (map & 0xF)
u8 vf_lmac_map[MAX_LMAC]; u8 vf_lmac_map[MAX_LMAC];
u8 lmac_cnt;
struct delayed_work dwork; struct delayed_work dwork;
struct workqueue_struct *check_link; struct workqueue_struct *check_link;
u8 link[MAX_LMAC]; u8 link[MAX_LMAC];
...@@ -279,6 +280,7 @@ static void nic_set_lmac_vf_mapping(struct nicpf *nic) ...@@ -279,6 +280,7 @@ static void nic_set_lmac_vf_mapping(struct nicpf *nic)
u64 lmac_credit; u64 lmac_credit;
nic->num_vf_en = 0; nic->num_vf_en = 0;
nic->lmac_cnt = 0;
for (bgx = 0; bgx < NIC_MAX_BGX; bgx++) { for (bgx = 0; bgx < NIC_MAX_BGX; bgx++) {
if (!(bgx_map & (1 << bgx))) if (!(bgx_map & (1 << bgx)))
...@@ -288,6 +290,7 @@ static void nic_set_lmac_vf_mapping(struct nicpf *nic) ...@@ -288,6 +290,7 @@ static void nic_set_lmac_vf_mapping(struct nicpf *nic)
nic->vf_lmac_map[next_bgx_lmac++] = nic->vf_lmac_map[next_bgx_lmac++] =
NIC_SET_VF_LMAC_MAP(bgx, lmac); NIC_SET_VF_LMAC_MAP(bgx, lmac);
nic->num_vf_en += lmac_cnt; nic->num_vf_en += lmac_cnt;
nic->lmac_cnt += lmac_cnt;
/* Program LMAC credits */ /* Program LMAC credits */
lmac_credit = (1ull << 1); /* channel credit enable */ lmac_credit = (1ull << 1); /* channel credit enable */
...@@ -715,6 +718,13 @@ static void nic_handle_mbx_intr(struct nicpf *nic, int vf) ...@@ -715,6 +718,13 @@ static void nic_handle_mbx_intr(struct nicpf *nic, int vf)
case NIC_MBOX_MSG_CFG_DONE: case NIC_MBOX_MSG_CFG_DONE:
/* Last message of VF config msg sequence */ /* Last message of VF config msg sequence */
nic->vf_enabled[vf] = true; nic->vf_enabled[vf] = true;
if (vf >= nic->lmac_cnt)
goto unlock;
bgx = NIC_GET_BGX_FROM_VF_LMAC_MAP(nic->vf_lmac_map[vf]);
lmac = NIC_GET_LMAC_FROM_VF_LMAC_MAP(nic->vf_lmac_map[vf]);
bgx_lmac_rx_tx_enable(nic->node, bgx, lmac, true);
goto unlock; goto unlock;
case NIC_MBOX_MSG_SHUTDOWN: case NIC_MBOX_MSG_SHUTDOWN:
/* First msg in VF teardown sequence */ /* First msg in VF teardown sequence */
...@@ -722,6 +732,14 @@ static void nic_handle_mbx_intr(struct nicpf *nic, int vf) ...@@ -722,6 +732,14 @@ static void nic_handle_mbx_intr(struct nicpf *nic, int vf)
if (vf >= nic->num_vf_en) if (vf >= nic->num_vf_en)
nic->sqs_used[vf - nic->num_vf_en] = false; nic->sqs_used[vf - nic->num_vf_en] = false;
nic->pqs_vf[vf] = 0; nic->pqs_vf[vf] = 0;
if (vf >= nic->lmac_cnt)
break;
bgx = NIC_GET_BGX_FROM_VF_LMAC_MAP(nic->vf_lmac_map[vf]);
lmac = NIC_GET_LMAC_FROM_VF_LMAC_MAP(nic->vf_lmac_map[vf]);
bgx_lmac_rx_tx_enable(nic->node, bgx, lmac, false);
break; break;
case NIC_MBOX_MSG_ALLOC_SQS: case NIC_MBOX_MSG_ALLOC_SQS:
nic_alloc_sqs(nic, &mbx.sqs_alloc); nic_alloc_sqs(nic, &mbx.sqs_alloc);
...@@ -940,7 +958,7 @@ static void nic_poll_for_link(struct work_struct *work) ...@@ -940,7 +958,7 @@ static void nic_poll_for_link(struct work_struct *work)
mbx.link_status.msg = NIC_MBOX_MSG_BGX_LINK_CHANGE; mbx.link_status.msg = NIC_MBOX_MSG_BGX_LINK_CHANGE;
for (vf = 0; vf < nic->num_vf_en; vf++) { for (vf = 0; vf < nic->lmac_cnt; vf++) {
/* Poll only if VF is UP */ /* Poll only if VF is UP */
if (!nic->vf_enabled[vf]) if (!nic->vf_enabled[vf])
continue; continue;
......
...@@ -186,6 +186,23 @@ void bgx_set_lmac_mac(int node, int bgx_idx, int lmacid, const u8 *mac) ...@@ -186,6 +186,23 @@ void bgx_set_lmac_mac(int node, int bgx_idx, int lmacid, const u8 *mac)
} }
EXPORT_SYMBOL(bgx_set_lmac_mac); EXPORT_SYMBOL(bgx_set_lmac_mac);
void bgx_lmac_rx_tx_enable(int node, int bgx_idx, int lmacid, bool enable)
{
struct bgx *bgx = bgx_vnic[(node * MAX_BGX_PER_CN88XX) + bgx_idx];
u64 cfg;
if (!bgx)
return;
cfg = bgx_reg_read(bgx, lmacid, BGX_CMRX_CFG);
if (enable)
cfg |= CMR_PKT_RX_EN | CMR_PKT_TX_EN;
else
cfg &= ~(CMR_PKT_RX_EN | CMR_PKT_TX_EN);
bgx_reg_write(bgx, lmacid, BGX_CMRX_CFG, cfg);
}
EXPORT_SYMBOL(bgx_lmac_rx_tx_enable);
static void bgx_sgmii_change_link_state(struct lmac *lmac) static void bgx_sgmii_change_link_state(struct lmac *lmac)
{ {
struct bgx *bgx = lmac->bgx; struct bgx *bgx = lmac->bgx;
...@@ -656,8 +673,7 @@ static int bgx_lmac_enable(struct bgx *bgx, u8 lmacid) ...@@ -656,8 +673,7 @@ static int bgx_lmac_enable(struct bgx *bgx, u8 lmacid)
} }
/* Enable lmac */ /* Enable lmac */
bgx_reg_modify(bgx, lmacid, BGX_CMRX_CFG, bgx_reg_modify(bgx, lmacid, BGX_CMRX_CFG, CMR_EN);
CMR_EN | CMR_PKT_RX_EN | CMR_PKT_TX_EN);
/* Restore default cfg, incase low level firmware changed it */ /* Restore default cfg, incase low level firmware changed it */
bgx_reg_write(bgx, lmacid, BGX_CMRX_RX_DMAC_CTL, 0x03); bgx_reg_write(bgx, lmacid, BGX_CMRX_RX_DMAC_CTL, 0x03);
......
...@@ -183,6 +183,7 @@ enum MCAST_MODE { ...@@ -183,6 +183,7 @@ enum MCAST_MODE {
#define CAM_ACCEPT 1 #define CAM_ACCEPT 1
void octeon_mdiobus_force_mod_depencency(void); void octeon_mdiobus_force_mod_depencency(void);
void bgx_lmac_rx_tx_enable(int node, int bgx_idx, int lmacid, bool enable);
void bgx_add_dmac_addr(u64 dmac, int node, int bgx_idx, int lmac); void bgx_add_dmac_addr(u64 dmac, int node, int bgx_idx, int lmac);
unsigned bgx_get_map(int node); unsigned bgx_get_map(int node);
int bgx_get_lmac_count(int node, int bgx); int bgx_get_lmac_count(int node, int bgx);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment