net/bnxt: support async link notification
This patch adds support to get Link notification asynchronously. The HW sends async notifications on default completion ring. The PMD processes these notifications and logs a message appropriately. Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
This commit is contained in:
parent
93b7c9d8b7
commit
7bc8e9a227
@ -59,6 +59,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_stats.c
|
||||
SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_txq.c
|
||||
SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_txr.c
|
||||
SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_vnic.c
|
||||
SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_irq.c
|
||||
|
||||
#
|
||||
# Export include files
|
||||
|
@ -95,7 +95,7 @@ struct bnxt_pf_info {
|
||||
#define BNXT_LINK_WAIT_CNT 10
|
||||
#define BNXT_LINK_WAIT_INTERVAL 100
|
||||
struct bnxt_link_info {
|
||||
uint8_t phy_flags;
|
||||
uint32_t phy_flags;
|
||||
uint8_t mac_type;
|
||||
uint8_t phy_link_status;
|
||||
uint8_t loop_back;
|
||||
@ -159,6 +159,8 @@ struct bnxt {
|
||||
#define MAX_FF_POOLS ETH_64_POOLS
|
||||
STAILQ_HEAD(, bnxt_vnic_info) ff_pool[MAX_FF_POOLS];
|
||||
|
||||
struct bnxt_irq *irq_tbl;
|
||||
|
||||
#define MAX_NUM_MAC_ADDR 32
|
||||
uint8_t mac_addr[ETHER_ADDR_LEN];
|
||||
|
||||
@ -178,4 +180,6 @@ struct bnxt {
|
||||
uint8_t dev_stopped;
|
||||
};
|
||||
|
||||
int bnxt_link_update_op(struct rte_eth_dev *eth_dev, int wait_to_complete);
|
||||
|
||||
#endif
|
||||
|
@ -42,28 +42,23 @@
|
||||
/*
|
||||
* Async event handling
|
||||
*/
|
||||
void bnxt_handle_async_event(struct bnxt *bp __rte_unused,
|
||||
void bnxt_handle_async_event(struct bnxt *bp,
|
||||
struct cmpl_base *cmp)
|
||||
{
|
||||
struct hwrm_async_event_cmpl *async_cmp =
|
||||
(struct hwrm_async_event_cmpl *)cmp;
|
||||
uint16_t event_id = rte_le_to_cpu_16(async_cmp->event_id);
|
||||
|
||||
/* TODO: HWRM async events are not defined yet */
|
||||
/* Needs to handle: link events, error events, etc. */
|
||||
switch (async_cmp->event_id) {
|
||||
case 0:
|
||||
/* Assume LINK_CHANGE == 0 */
|
||||
RTE_LOG(INFO, PMD, "Link change event\n");
|
||||
|
||||
/* Can just prompt the update_op routine to do a qcfg
|
||||
* instead of doing the actual qcfg
|
||||
*/
|
||||
break;
|
||||
case 1:
|
||||
switch (event_id) {
|
||||
case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_STATUS_CHANGE:
|
||||
case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_SPEED_CHANGE:
|
||||
case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_SPEED_CFG_CHANGE:
|
||||
bnxt_link_update_op(bp->eth_dev, 0);
|
||||
break;
|
||||
default:
|
||||
RTE_LOG(ERR, PMD, "handle_async_event id = 0x%x\n",
|
||||
async_cmp->event_id);
|
||||
RTE_LOG(ERR, PMD, "handle_async_event id = 0x%x\n", event_id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -43,6 +43,7 @@
|
||||
#include "bnxt_cpr.h"
|
||||
#include "bnxt_filter.h"
|
||||
#include "bnxt_hwrm.h"
|
||||
#include "bnxt_irq.h"
|
||||
#include "bnxt_ring.h"
|
||||
#include "bnxt_rxq.h"
|
||||
#include "bnxt_rxr.h"
|
||||
@ -189,6 +190,7 @@ static int bnxt_alloc_mem(struct bnxt *bp)
|
||||
static int bnxt_init_chip(struct bnxt *bp)
|
||||
{
|
||||
unsigned int i, rss_idx, fw_idx;
|
||||
struct rte_eth_link new;
|
||||
int rc;
|
||||
|
||||
rc = bnxt_alloc_all_hwrm_stat_ctxs(bp);
|
||||
@ -275,6 +277,21 @@ static int bnxt_init_chip(struct bnxt *bp)
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
rc = bnxt_get_hwrm_link_config(bp, &new);
|
||||
if (rc) {
|
||||
RTE_LOG(ERR, PMD, "HWRM Get link config failure rc: %x\n", rc);
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
if (!bp->link_info.link_up) {
|
||||
rc = bnxt_set_hwrm_link_config(bp, true);
|
||||
if (rc) {
|
||||
RTE_LOG(ERR, PMD,
|
||||
"HWRM link config failure rc: %x\n", rc);
|
||||
goto err_out;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
err_out:
|
||||
@ -366,6 +383,8 @@ static void bnxt_dev_info_get_op(struct rte_eth_dev *eth_dev,
|
||||
.txq_flags = ETH_TXQ_FLAGS_NOMULTSEGS |
|
||||
ETH_TXQ_FLAGS_NOOFFLOADS,
|
||||
};
|
||||
eth_dev->data->dev_conf.intr_conf.lsc = 1;
|
||||
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/*
|
||||
@ -404,7 +423,6 @@ static void bnxt_dev_info_get_op(struct rte_eth_dev *eth_dev,
|
||||
static int bnxt_dev_configure_op(struct rte_eth_dev *eth_dev)
|
||||
{
|
||||
struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
|
||||
int rc;
|
||||
|
||||
bp->rx_queues = (void *)eth_dev->data->rx_queues;
|
||||
bp->tx_queues = (void *)eth_dev->data->tx_queues;
|
||||
@ -419,8 +437,42 @@ static int bnxt_dev_configure_op(struct rte_eth_dev *eth_dev)
|
||||
eth_dev->data->mtu =
|
||||
eth_dev->data->dev_conf.rxmode.max_rx_pkt_len -
|
||||
ETHER_HDR_LEN - ETHER_CRC_LEN - VLAN_TAG_SIZE;
|
||||
rc = bnxt_set_hwrm_link_config(bp, true);
|
||||
return rc;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
rte_bnxt_atomic_write_link_status(struct rte_eth_dev *eth_dev,
|
||||
struct rte_eth_link *link)
|
||||
{
|
||||
struct rte_eth_link *dst = ð_dev->data->dev_link;
|
||||
struct rte_eth_link *src = link;
|
||||
|
||||
if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst,
|
||||
*(uint64_t *)src) == 0)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void bnxt_print_link_info(struct rte_eth_dev *eth_dev)
|
||||
{
|
||||
struct rte_eth_link *link = ð_dev->data->dev_link;
|
||||
|
||||
if (link->link_status)
|
||||
RTE_LOG(INFO, PMD, "Port %d Link Up - speed %u Mbps - %s\n",
|
||||
(uint8_t)(eth_dev->data->port_id),
|
||||
(uint32_t)link->link_speed,
|
||||
(link->link_duplex == ETH_LINK_FULL_DUPLEX) ?
|
||||
("full-duplex") : ("half-duplex\n"));
|
||||
else
|
||||
RTE_LOG(INFO, PMD, "Port %d Link Down\n",
|
||||
(uint8_t)(eth_dev->data->port_id));
|
||||
}
|
||||
|
||||
static int bnxt_dev_lsc_intr_setup(struct rte_eth_dev *eth_dev)
|
||||
{
|
||||
bnxt_print_link_info(eth_dev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int bnxt_dev_start_op(struct rte_eth_dev *eth_dev)
|
||||
@ -436,18 +488,31 @@ static int bnxt_dev_start_op(struct rte_eth_dev *eth_dev)
|
||||
goto error;
|
||||
}
|
||||
|
||||
rc = bnxt_setup_int(bp);
|
||||
if (rc)
|
||||
goto error;
|
||||
|
||||
rc = bnxt_alloc_mem(bp);
|
||||
if (rc)
|
||||
goto error;
|
||||
|
||||
rc = bnxt_request_int(bp);
|
||||
if (rc)
|
||||
goto error;
|
||||
|
||||
rc = bnxt_init_nic(bp);
|
||||
if (rc)
|
||||
goto error;
|
||||
|
||||
bnxt_enable_int(bp);
|
||||
|
||||
bnxt_link_update_op(eth_dev, 0);
|
||||
return 0;
|
||||
|
||||
error:
|
||||
bnxt_shutdown_nic(bp);
|
||||
bnxt_disable_int(bp);
|
||||
bnxt_free_int(bp);
|
||||
bnxt_free_tx_mbufs(bp);
|
||||
bnxt_free_rx_mbufs(bp);
|
||||
bnxt_free_mem(bp);
|
||||
@ -482,6 +547,8 @@ static void bnxt_dev_stop_op(struct rte_eth_dev *eth_dev)
|
||||
eth_dev->data->dev_link.link_status = 0;
|
||||
}
|
||||
bnxt_set_hwrm_link_config(bp, false);
|
||||
bnxt_disable_int(bp);
|
||||
bnxt_free_int(bp);
|
||||
bnxt_shutdown_nic(bp);
|
||||
bp->dev_stopped = 1;
|
||||
}
|
||||
@ -580,8 +647,7 @@ static void bnxt_mac_addr_add_op(struct rte_eth_dev *eth_dev,
|
||||
bnxt_hwrm_set_filter(bp, vnic, filter);
|
||||
}
|
||||
|
||||
static int bnxt_link_update_op(struct rte_eth_dev *eth_dev,
|
||||
int wait_to_complete)
|
||||
int bnxt_link_update_op(struct rte_eth_dev *eth_dev, int wait_to_complete)
|
||||
{
|
||||
int rc = 0;
|
||||
struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
|
||||
@ -599,21 +665,20 @@ static int bnxt_link_update_op(struct rte_eth_dev *eth_dev,
|
||||
"Failed to retrieve link rc = 0x%x!", rc);
|
||||
goto out;
|
||||
}
|
||||
if (!wait_to_complete)
|
||||
break;
|
||||
|
||||
rte_delay_ms(BNXT_LINK_WAIT_INTERVAL);
|
||||
|
||||
if (!wait_to_complete)
|
||||
break;
|
||||
} while (!new.link_status && cnt--);
|
||||
|
||||
/* Timed out or success */
|
||||
if (new.link_status) {
|
||||
/* Update only if success */
|
||||
eth_dev->data->dev_link.link_duplex = new.link_duplex;
|
||||
eth_dev->data->dev_link.link_speed = new.link_speed;
|
||||
}
|
||||
eth_dev->data->dev_link.link_status = new.link_status;
|
||||
out:
|
||||
/* Timed out or success */
|
||||
if (new.link_status != eth_dev->data->dev_link.link_status ||
|
||||
new.link_speed != eth_dev->data->dev_link.link_speed) {
|
||||
rte_bnxt_atomic_write_link_status(eth_dev, &new);
|
||||
bnxt_print_link_info(eth_dev);
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -724,6 +789,11 @@ static int bnxt_reta_query_op(struct rte_eth_dev *eth_dev,
|
||||
/* EW - need to revisit here copying from u64 to u16 */
|
||||
memcpy(reta_conf, vnic->rss_table, reta_size);
|
||||
|
||||
if (rte_intr_allow_others(ð_dev->pci_dev->intr_handle)) {
|
||||
if (eth_dev->data->dev_conf.intr_conf.lsc != 0)
|
||||
bnxt_dev_lsc_intr_setup(eth_dev);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1122,7 +1192,7 @@ static struct eth_driver bnxt_rte_pmd = {
|
||||
.pci_drv = {
|
||||
.id_table = bnxt_pci_id_map,
|
||||
.drv_flags = RTE_PCI_DRV_NEED_MAPPING |
|
||||
RTE_PCI_DRV_DETACHABLE,
|
||||
RTE_PCI_DRV_DETACHABLE | RTE_PCI_DRV_INTR_LSC,
|
||||
.probe = rte_eth_dev_pci_probe,
|
||||
.remove = rte_eth_dev_pci_remove
|
||||
},
|
||||
|
@ -342,13 +342,16 @@ int bnxt_hwrm_func_driver_register(struct bnxt *bp, uint32_t flags,
|
||||
|
||||
HWRM_PREP(req, FUNC_DRV_RGTR, -1, resp);
|
||||
req.flags = flags;
|
||||
req.enables = HWRM_FUNC_DRV_RGTR_INPUT_ENABLES_VER;
|
||||
req.enables = HWRM_FUNC_DRV_RGTR_INPUT_ENABLES_VER |
|
||||
HWRM_FUNC_DRV_RGTR_INPUT_ENABLES_ASYNC_EVENT_FWD;
|
||||
req.ver_maj = RTE_VER_YEAR;
|
||||
req.ver_min = RTE_VER_MONTH;
|
||||
req.ver_upd = RTE_VER_MINOR;
|
||||
|
||||
memcpy(req.vf_req_fwd, vf_req_fwd, sizeof(req.vf_req_fwd));
|
||||
|
||||
req.async_event_fwd[0] |= rte_cpu_to_le_32(0x1); /* TODO: Use MACRO */
|
||||
|
||||
rc = bnxt_hwrm_send_message(bp, &req, sizeof(req));
|
||||
|
||||
HWRM_CHECK_RESULT;
|
||||
@ -470,49 +473,44 @@ int bnxt_hwrm_func_driver_unregister(struct bnxt *bp, uint32_t flags)
|
||||
static int bnxt_hwrm_port_phy_cfg(struct bnxt *bp, struct bnxt_link_info *conf)
|
||||
{
|
||||
int rc = 0;
|
||||
struct hwrm_port_phy_cfg_input req = {.req_type = 0};
|
||||
struct hwrm_port_phy_cfg_input req = {0};
|
||||
struct hwrm_port_phy_cfg_output *resp = bp->hwrm_cmd_resp_addr;
|
||||
uint32_t enables = 0;
|
||||
|
||||
HWRM_PREP(req, PORT_PHY_CFG, -1, resp);
|
||||
|
||||
req.flags = conf->phy_flags;
|
||||
if (conf->link_up) {
|
||||
req.force_link_speed = conf->link_speed;
|
||||
req.flags = rte_cpu_to_le_32(conf->phy_flags);
|
||||
req.force_link_speed = rte_cpu_to_le_16(conf->link_speed);
|
||||
/*
|
||||
* Note, ChiMP FW 20.2.1 and 20.2.2 return an error when we set
|
||||
* any auto mode, even "none".
|
||||
*/
|
||||
if (req.auto_mode == HWRM_PORT_PHY_CFG_INPUT_AUTO_MODE_NONE) {
|
||||
req.flags |= HWRM_PORT_PHY_CFG_INPUT_FLAGS_FORCE;
|
||||
} else {
|
||||
req.auto_mode = conf->auto_mode;
|
||||
req.enables |=
|
||||
HWRM_PORT_PHY_CFG_INPUT_ENABLES_AUTO_MODE;
|
||||
if (!conf->link_speed) {
|
||||
req.auto_mode |= conf->auto_mode;
|
||||
enables = HWRM_PORT_PHY_CFG_INPUT_ENABLES_AUTO_MODE;
|
||||
req.auto_link_speed_mask = conf->auto_link_speed_mask;
|
||||
req.enables |=
|
||||
enables |=
|
||||
HWRM_PORT_PHY_CFG_INPUT_ENABLES_AUTO_LINK_SPEED_MASK;
|
||||
req.auto_link_speed = conf->auto_link_speed;
|
||||
req.enables |=
|
||||
req.auto_link_speed = bp->link_info.auto_link_speed;
|
||||
enables |=
|
||||
HWRM_PORT_PHY_CFG_INPUT_ENABLES_AUTO_LINK_SPEED;
|
||||
}
|
||||
req.auto_duplex = conf->duplex;
|
||||
req.enables |= HWRM_PORT_PHY_CFG_INPUT_ENABLES_AUTO_DUPLEX;
|
||||
enables |= HWRM_PORT_PHY_CFG_INPUT_ENABLES_AUTO_DUPLEX;
|
||||
req.auto_pause = conf->auto_pause;
|
||||
/* Set force_pause if there is no auto or if there is a force */
|
||||
if (req.auto_pause)
|
||||
req.enables |=
|
||||
HWRM_PORT_PHY_CFG_INPUT_ENABLES_AUTO_PAUSE;
|
||||
else
|
||||
req.enables |=
|
||||
HWRM_PORT_PHY_CFG_INPUT_ENABLES_FORCE_PAUSE;
|
||||
req.force_pause = conf->force_pause;
|
||||
if (req.force_pause)
|
||||
req.enables |=
|
||||
HWRM_PORT_PHY_CFG_INPUT_ENABLES_FORCE_PAUSE;
|
||||
/* Set force_pause if there is no auto or if there is a force */
|
||||
if (req.auto_pause && !req.force_pause)
|
||||
enables |= HWRM_PORT_PHY_CFG_INPUT_ENABLES_AUTO_PAUSE;
|
||||
else
|
||||
enables |= HWRM_PORT_PHY_CFG_INPUT_ENABLES_FORCE_PAUSE;
|
||||
|
||||
req.enables = rte_cpu_to_le_32(enables);
|
||||
} else {
|
||||
req.flags &= ~HWRM_PORT_PHY_CFG_INPUT_FLAGS_RESTART_AUTONEG;
|
||||
req.flags |= HWRM_PORT_PHY_CFG_INPUT_FLAGS_FORCE_LINK_DOWN;
|
||||
req.force_link_speed = 0;
|
||||
req.flags =
|
||||
rte_cpu_to_le_32(HWRM_PORT_PHY_CFG_INPUT_FLAGS_FORCE_LINK_DOWN);
|
||||
RTE_LOG(INFO, PMD, "Force Link Down\n");
|
||||
}
|
||||
|
||||
rc = bnxt_hwrm_send_message(bp, &req, sizeof(req));
|
||||
@ -526,7 +524,7 @@ static int bnxt_hwrm_port_phy_qcfg(struct bnxt *bp,
|
||||
struct bnxt_link_info *link_info)
|
||||
{
|
||||
int rc = 0;
|
||||
struct hwrm_port_phy_qcfg_input req = {.req_type = 0};
|
||||
struct hwrm_port_phy_qcfg_input req = {0};
|
||||
struct hwrm_port_phy_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
|
||||
|
||||
HWRM_PREP(req, PORT_PHY_QCFG, -1, resp);
|
||||
@ -536,7 +534,7 @@ static int bnxt_hwrm_port_phy_qcfg(struct bnxt *bp,
|
||||
HWRM_CHECK_RESULT;
|
||||
|
||||
link_info->phy_link_status = resp->link;
|
||||
if (link_info->phy_link_status == HWRM_PORT_PHY_QCFG_OUTPUT_LINK_LINK) {
|
||||
if (link_info->phy_link_status != HWRM_PORT_PHY_QCFG_OUTPUT_LINK_NO_LINK) {
|
||||
link_info->link_up = 1;
|
||||
link_info->link_speed = rte_le_to_cpu_16(resp->link_speed);
|
||||
} else {
|
||||
@ -811,7 +809,7 @@ int bnxt_hwrm_stat_ctx_free(struct bnxt *bp,
|
||||
int bnxt_hwrm_vnic_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic)
|
||||
{
|
||||
int rc = 0, i, j;
|
||||
struct hwrm_vnic_alloc_input req = {.req_type = 0 };
|
||||
struct hwrm_vnic_alloc_input req = { 0 };
|
||||
struct hwrm_vnic_alloc_output *resp = bp->hwrm_cmd_resp_addr;
|
||||
|
||||
/* map ring groups to this vnic */
|
||||
@ -1252,42 +1250,42 @@ static uint16_t bnxt_parse_eth_link_speed(uint32_t conf_link_speed)
|
||||
{
|
||||
uint16_t eth_link_speed = 0;
|
||||
|
||||
if ((conf_link_speed & ETH_LINK_SPEED_FIXED) == ETH_LINK_SPEED_AUTONEG)
|
||||
if (conf_link_speed == ETH_LINK_SPEED_AUTONEG)
|
||||
return ETH_LINK_SPEED_AUTONEG;
|
||||
|
||||
switch (conf_link_speed & ~ETH_LINK_SPEED_FIXED) {
|
||||
case ETH_LINK_SPEED_100M:
|
||||
case ETH_LINK_SPEED_100M_HD:
|
||||
eth_link_speed =
|
||||
HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_10MB;
|
||||
HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_100MB;
|
||||
break;
|
||||
case ETH_LINK_SPEED_1G:
|
||||
eth_link_speed =
|
||||
HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_1GB;
|
||||
HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_1GB;
|
||||
break;
|
||||
case ETH_LINK_SPEED_2_5G:
|
||||
eth_link_speed =
|
||||
HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_2_5GB;
|
||||
HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_2_5GB;
|
||||
break;
|
||||
case ETH_LINK_SPEED_10G:
|
||||
eth_link_speed =
|
||||
HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_10GB;
|
||||
HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_10GB;
|
||||
break;
|
||||
case ETH_LINK_SPEED_20G:
|
||||
eth_link_speed =
|
||||
HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_20GB;
|
||||
HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_20GB;
|
||||
break;
|
||||
case ETH_LINK_SPEED_25G:
|
||||
eth_link_speed =
|
||||
HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_25GB;
|
||||
HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_25GB;
|
||||
break;
|
||||
case ETH_LINK_SPEED_40G:
|
||||
eth_link_speed =
|
||||
HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_40GB;
|
||||
HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_40GB;
|
||||
break;
|
||||
case ETH_LINK_SPEED_50G:
|
||||
eth_link_speed =
|
||||
HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_50GB;
|
||||
HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_50GB;
|
||||
break;
|
||||
default:
|
||||
RTE_LOG(ERR, PMD,
|
||||
@ -1463,33 +1461,36 @@ int bnxt_set_hwrm_link_config(struct bnxt *bp, bool link_up)
|
||||
goto error;
|
||||
|
||||
memset(&link_req, 0, sizeof(link_req));
|
||||
speed = bnxt_parse_eth_link_speed(dev_conf->link_speeds);
|
||||
link_req.link_up = link_up;
|
||||
if (!link_up)
|
||||
goto port_phy_cfg;
|
||||
|
||||
speed = bnxt_parse_eth_link_speed(dev_conf->link_speeds);
|
||||
link_req.phy_flags = HWRM_PORT_PHY_CFG_INPUT_FLAGS_RESET_PHY;
|
||||
if (speed == 0) {
|
||||
link_req.phy_flags =
|
||||
link_req.phy_flags |=
|
||||
HWRM_PORT_PHY_CFG_INPUT_FLAGS_RESTART_AUTONEG;
|
||||
link_req.auto_mode =
|
||||
HWRM_PORT_PHY_CFG_INPUT_AUTO_MODE_ONE_OR_BELOW;
|
||||
HWRM_PORT_PHY_CFG_INPUT_AUTO_MODE_SPEED_MASK;
|
||||
link_req.auto_link_speed_mask =
|
||||
bnxt_parse_eth_link_speed_mask(dev_conf->link_speeds);
|
||||
link_req.auto_link_speed =
|
||||
HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_50GB;
|
||||
} else {
|
||||
link_req.auto_mode = HWRM_PORT_PHY_CFG_INPUT_AUTO_MODE_NONE;
|
||||
link_req.phy_flags = HWRM_PORT_PHY_CFG_INPUT_FLAGS_FORCE |
|
||||
HWRM_PORT_PHY_CFG_INPUT_FLAGS_RESET_PHY;
|
||||
link_req.phy_flags |= HWRM_PORT_PHY_CFG_INPUT_FLAGS_FORCE;
|
||||
link_req.link_speed = speed;
|
||||
RTE_LOG(INFO, PMD, "Set Link Speed %x\n", speed);
|
||||
}
|
||||
link_req.duplex = bnxt_parse_eth_link_duplex(dev_conf->link_speeds);
|
||||
link_req.auto_pause = bp->link_info.auto_pause;
|
||||
link_req.force_pause = bp->link_info.force_pause;
|
||||
|
||||
port_phy_cfg:
|
||||
rc = bnxt_hwrm_port_phy_cfg(bp, &link_req);
|
||||
if (rc) {
|
||||
RTE_LOG(ERR, PMD,
|
||||
"Set link config failed with rc %d\n", rc);
|
||||
}
|
||||
|
||||
rte_delay_ms(BNXT_LINK_WAIT_INTERVAL);
|
||||
error:
|
||||
return rc;
|
||||
}
|
||||
|
156
drivers/net/bnxt/bnxt_irq.c
Normal file
156
drivers/net/bnxt/bnxt_irq.c
Normal file
@ -0,0 +1,156 @@
|
||||
/*-
|
||||
* BSD LICENSE
|
||||
*
|
||||
* Copyright(c) 2014-2015 Broadcom Corporation.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Broadcom Corporation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#include <rte_malloc.h>
|
||||
|
||||
#include "bnxt.h"
|
||||
#include "bnxt_cpr.h"
|
||||
#include "bnxt_irq.h"
|
||||
#include "bnxt_ring.h"
|
||||
#include "hsi_struct_def_dpdk.h"
|
||||
|
||||
/*
|
||||
* Interrupts
|
||||
*/
|
||||
|
||||
static void bnxt_int_handler(struct rte_intr_handle *handle __rte_unused,
|
||||
void *param)
|
||||
{
|
||||
struct rte_eth_dev *eth_dev = (struct rte_eth_dev *)param;
|
||||
struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
|
||||
struct bnxt_cp_ring_info *cpr = bp->def_cp_ring;
|
||||
uint32_t raw_cons = cpr->cp_raw_cons;
|
||||
uint32_t cons;
|
||||
struct cmpl_base *cmp;
|
||||
|
||||
while (1) {
|
||||
cons = RING_CMP(cpr->cp_ring_struct, raw_cons);
|
||||
cmp = &cpr->cp_desc_ring[cons];
|
||||
|
||||
if (!CMP_VALID(cmp, raw_cons, cpr->cp_ring_struct))
|
||||
break;
|
||||
|
||||
switch (CMP_TYPE(cmp)) {
|
||||
case CMPL_BASE_TYPE_HWRM_ASYNC_EVENT:
|
||||
/* Handle any async event */
|
||||
bnxt_handle_async_event(bp, cmp);
|
||||
break;
|
||||
case CMPL_BASE_TYPE_HWRM_FWD_RESP:
|
||||
/* Handle HWRM forwarded responses */
|
||||
bnxt_handle_fwd_req(bp, cmp);
|
||||
break;
|
||||
default:
|
||||
/* Ignore any other events */
|
||||
break;
|
||||
}
|
||||
raw_cons = NEXT_RAW_CMP(raw_cons);
|
||||
}
|
||||
B_CP_DB_REARM(cpr, cpr->cp_raw_cons);
|
||||
}
|
||||
|
||||
void bnxt_free_int(struct bnxt *bp)
|
||||
{
|
||||
struct bnxt_irq *irq;
|
||||
|
||||
irq = bp->irq_tbl;
|
||||
if (irq) {
|
||||
if (irq->requested) {
|
||||
rte_intr_disable(&bp->pdev->intr_handle);
|
||||
rte_intr_callback_unregister(&bp->pdev->intr_handle,
|
||||
irq->handler,
|
||||
(void *)bp->eth_dev);
|
||||
irq->requested = 0;
|
||||
}
|
||||
rte_free((void *)bp->irq_tbl);
|
||||
bp->irq_tbl = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void bnxt_disable_int(struct bnxt *bp)
|
||||
{
|
||||
struct bnxt_cp_ring_info *cpr = bp->def_cp_ring;
|
||||
|
||||
/* Only the default completion ring */
|
||||
B_CP_DIS_DB(cpr, cpr->cp_raw_cons);
|
||||
}
|
||||
|
||||
void bnxt_enable_int(struct bnxt *bp)
|
||||
{
|
||||
struct bnxt_cp_ring_info *cpr = bp->def_cp_ring;
|
||||
|
||||
B_CP_DB_REARM(cpr, cpr->cp_raw_cons);
|
||||
}
|
||||
|
||||
int bnxt_setup_int(struct bnxt *bp)
|
||||
{
|
||||
uint16_t total_vecs;
|
||||
const int len = sizeof(bp->irq_tbl[0].name);
|
||||
int i, rc = 0;
|
||||
|
||||
/* DPDK host only supports 1 MSI-X vector */
|
||||
total_vecs = 1;
|
||||
bp->irq_tbl = rte_calloc("bnxt_irq_tbl", total_vecs,
|
||||
sizeof(struct bnxt_irq), 0);
|
||||
if (bp->irq_tbl) {
|
||||
for (i = 0; i < total_vecs; i++) {
|
||||
bp->irq_tbl[i].vector = i;
|
||||
snprintf(bp->irq_tbl[i].name, len,
|
||||
"%s-%d", bp->eth_dev->data->name, i);
|
||||
bp->irq_tbl[i].handler = bnxt_int_handler;
|
||||
}
|
||||
} else {
|
||||
rc = -ENOMEM;
|
||||
goto setup_exit;
|
||||
}
|
||||
return 0;
|
||||
|
||||
setup_exit:
|
||||
RTE_LOG(ERR, PMD, "bnxt_irq_tbl setup failed");
|
||||
return rc;
|
||||
}
|
||||
|
||||
int bnxt_request_int(struct bnxt *bp)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
struct bnxt_irq *irq = bp->irq_tbl;
|
||||
|
||||
rte_intr_callback_register(&bp->pdev->intr_handle, irq->handler,
|
||||
(void *)bp->eth_dev);
|
||||
rte_intr_enable(&bp->pdev->intr_handle);
|
||||
|
||||
irq->requested = 1;
|
||||
return rc;
|
||||
}
|
51
drivers/net/bnxt/bnxt_irq.h
Normal file
51
drivers/net/bnxt/bnxt_irq.h
Normal file
@ -0,0 +1,51 @@
|
||||
/*-
|
||||
* BSD LICENSE
|
||||
*
|
||||
* Copyright(c) 2014-2015 Broadcom Corporation.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Broadcom Corporation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _BNXT_IRQ_H_
|
||||
#define _BNXT_IRQ_H_
|
||||
|
||||
struct bnxt_irq {
|
||||
rte_intr_callback_fn handler;
|
||||
unsigned int vector;
|
||||
uint8_t requested;
|
||||
char name[RTE_ETH_NAME_MAX_LEN + 2];
|
||||
};
|
||||
|
||||
struct bnxt;
|
||||
void bnxt_free_int(struct bnxt *bp);
|
||||
void bnxt_disable_int(struct bnxt *bp);
|
||||
void bnxt_enable_int(struct bnxt *bp);
|
||||
int bnxt_setup_int(struct bnxt *bp);
|
||||
int bnxt_request_int(struct bnxt *bp);
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user