DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 02/10] bnx2x: Remove unused preprocessor symbols and code
@ 2016-07-12 13:38 Chas Williams
  2016-07-12 13:38 ` [dpdk-dev] [PATCH 03/10] bnx2x: Remove delay during device startup Chas Williams
                   ` (8 more replies)
  0 siblings, 9 replies; 11+ messages in thread
From: Chas Williams @ 2016-07-12 13:38 UTC (permalink / raw)
  To: dev; +Cc: harish.patil, Chas Williams

ELINK_INCLUDE_EMUL and ELINK_INCLUDE_FPGA are never defined.  Remove them
along with enumeration constants dependent on their inclusion.

Fixes: 540a211084a7 ("bnx2x: driver core")

Signed-off-by: Chas Williams <3chas3@gmail.com>
---
 drivers/net/bnx2x/bnx2x.c |  28 ----
 drivers/net/bnx2x/elink.c | 392 ++++++++--------------------------------------
 drivers/net/bnx2x/elink.h |   4 -
 3 files changed, 64 insertions(+), 360 deletions(-)

diff --git a/drivers/net/bnx2x/bnx2x.c b/drivers/net/bnx2x/bnx2x.c
index 6edb2f9..7599e9c 100644
--- a/drivers/net/bnx2x/bnx2x.c
+++ b/drivers/net/bnx2x/bnx2x.c
@@ -7035,34 +7035,6 @@ static int bnx2x_initial_phy_init(struct bnx2x_softc *sc, int load_mode)
 
 	bnx2x_set_requested_fc(sc);
 
-	if (CHIP_REV_IS_SLOW(sc)) {
-		uint32_t bond = CHIP_BOND_ID(sc);
-		uint32_t feat = 0;
-
-		if (CHIP_IS_E2(sc) && CHIP_IS_MODE_4_PORT(sc)) {
-			feat |= ELINK_FEATURE_CONFIG_EMUL_DISABLE_BMAC;
-		} else if (bond & 0x4) {
-			if (CHIP_IS_E3(sc)) {
-				feat |= ELINK_FEATURE_CONFIG_EMUL_DISABLE_XMAC;
-			} else {
-				feat |= ELINK_FEATURE_CONFIG_EMUL_DISABLE_BMAC;
-			}
-		} else if (bond & 0x8) {
-			if (CHIP_IS_E3(sc)) {
-				feat |= ELINK_FEATURE_CONFIG_EMUL_DISABLE_UMAC;
-			} else {
-				feat |= ELINK_FEATURE_CONFIG_EMUL_DISABLE_EMAC;
-			}
-		}
-
-/* disable EMAC for E3 and above */
-		if (bond & 0x2) {
-			feat |= ELINK_FEATURE_CONFIG_EMUL_DISABLE_EMAC;
-		}
-
-		sc->link_params.feature_config_flags |= feat;
-	}
-
 	if (load_mode == LOAD_DIAG) {
 		lp->loopback_mode = ELINK_LOOPBACK_XGXS;
 /* Prefer doing PHY loopback at 10G speed, if possible */
diff --git a/drivers/net/bnx2x/elink.c b/drivers/net/bnx2x/elink.c
index b9149b8..3a3bb30 100644
--- a/drivers/net/bnx2x/elink.c
+++ b/drivers/net/bnx2x/elink.c
@@ -1586,26 +1586,6 @@ static elink_status_t elink_emac_enable(struct elink_params *params,
 	/* enable emac and not bmac */
 	REG_WR(sc, NIG_REG_EGRESS_EMAC0_PORT + port * 4, 1);
 
-#ifdef ELINK_INCLUDE_EMUL
-	/* for paladium */
-	if (CHIP_REV_IS_EMUL(sc)) {
-		/* Use lane 1 (of lanes 0-3) */
-		REG_WR(sc, NIG_REG_XGXS_LANE_SEL_P0 + port * 4, 1);
-		REG_WR(sc, NIG_REG_XGXS_SERDES0_MODE_SEL + port * 4, 1);
-	}
-	/* for fpga */
-	else
-#endif
-#ifdef ELINK_INCLUDE_FPGA
-	if (CHIP_REV_IS_FPGA(sc)) {
-		/* Use lane 1 (of lanes 0-3) */
-		PMD_DRV_LOG(DEBUG, "elink_emac_enable: Setting FPGA");
-
-		REG_WR(sc, NIG_REG_XGXS_LANE_SEL_P0 + port * 4, 1);
-		REG_WR(sc, NIG_REG_XGXS_SERDES0_MODE_SEL + port * 4, 0);
-	} else
-#endif
-		/* ASIC */
 	if (vars->phy_flags & PHY_XGXS_FLAG) {
 		uint32_t ser_lane = ((params->lane_config &
 				      PORT_HW_CFG_LANE_SWAP_CFG_MASTER_MASK) >>
@@ -1628,39 +1608,28 @@ static elink_status_t elink_emac_enable(struct elink_params *params,
 	elink_bits_en(sc, emac_base + EMAC_REG_EMAC_TX_MODE,
 		      EMAC_TX_MODE_RESET);
 
-#if defined(ELINK_INCLUDE_EMUL) || defined(ELINK_INCLUDE_FPGA)
-	if (CHIP_REV_IS_SLOW(sc)) {
-		/* config GMII mode */
-		val = REG_RD(sc, emac_base + EMAC_REG_EMAC_MODE);
-		elink_cb_reg_write(sc, emac_base + EMAC_REG_EMAC_MODE,
-				   (val | EMAC_MODE_PORT_GMII));
-	} else {		/* ASIC */
-#endif
-		/* pause enable/disable */
-		elink_bits_dis(sc, emac_base + EMAC_REG_EMAC_RX_MODE,
-			       EMAC_RX_MODE_FLOW_EN);
+	/* pause enable/disable */
+	elink_bits_dis(sc, emac_base + EMAC_REG_EMAC_RX_MODE,
+		       EMAC_RX_MODE_FLOW_EN);
 
-		elink_bits_dis(sc, emac_base + EMAC_REG_EMAC_TX_MODE,
-			       (EMAC_TX_MODE_EXT_PAUSE_EN |
-				EMAC_TX_MODE_FLOW_EN));
-		if (!(params->feature_config_flags &
-		      ELINK_FEATURE_CONFIG_PFC_ENABLED)) {
-			if (vars->flow_ctrl & ELINK_FLOW_CTRL_RX)
-				elink_bits_en(sc, emac_base +
-					      EMAC_REG_EMAC_RX_MODE,
-					      EMAC_RX_MODE_FLOW_EN);
-
-			if (vars->flow_ctrl & ELINK_FLOW_CTRL_TX)
-				elink_bits_en(sc, emac_base +
-					      EMAC_REG_EMAC_TX_MODE,
-					      (EMAC_TX_MODE_EXT_PAUSE_EN |
-					       EMAC_TX_MODE_FLOW_EN));
-		} else
-			elink_bits_en(sc, emac_base + EMAC_REG_EMAC_TX_MODE,
-				      EMAC_TX_MODE_FLOW_EN);
-#if defined(ELINK_INCLUDE_EMUL) || defined(ELINK_INCLUDE_FPGA)
-	}
-#endif
+	elink_bits_dis(sc, emac_base + EMAC_REG_EMAC_TX_MODE,
+		       (EMAC_TX_MODE_EXT_PAUSE_EN |
+			EMAC_TX_MODE_FLOW_EN));
+	if (!(params->feature_config_flags &
+	      ELINK_FEATURE_CONFIG_PFC_ENABLED)) {
+		if (vars->flow_ctrl & ELINK_FLOW_CTRL_RX)
+			elink_bits_en(sc, emac_base +
+				      EMAC_REG_EMAC_RX_MODE,
+				      EMAC_RX_MODE_FLOW_EN);
+
+		if (vars->flow_ctrl & ELINK_FLOW_CTRL_TX)
+			elink_bits_en(sc, emac_base +
+				      EMAC_REG_EMAC_TX_MODE,
+				      (EMAC_TX_MODE_EXT_PAUSE_EN |
+				       EMAC_TX_MODE_FLOW_EN));
+	} else
+		elink_bits_en(sc, emac_base + EMAC_REG_EMAC_TX_MODE,
+			      EMAC_TX_MODE_FLOW_EN);
 
 	/* KEEP_VLAN_TAG, promiscuous */
 	val = REG_RD(sc, emac_base + EMAC_REG_EMAC_RX_MODE);
@@ -1727,17 +1696,7 @@ static elink_status_t elink_emac_enable(struct elink_params *params,
 	REG_WR(sc, NIG_REG_EMAC0_PAUSE_OUT_EN + port * 4, val);
 	REG_WR(sc, NIG_REG_EGRESS_EMAC0_OUT_EN + port * 4, 0x1);
 
-#ifdef ELINK_INCLUDE_EMUL
-	if (CHIP_REV_IS_EMUL(sc)) {
-		/* Take the BigMac out of reset */
-		REG_WR(sc, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_2_SET,
-		       (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << port));
-
-		/* Enable access for bmac registers */
-		REG_WR(sc, NIG_REG_BMAC0_REGS_OUT_EN + port * 4, 0x1);
-	} else
-#endif
-		REG_WR(sc, NIG_REG_BMAC0_REGS_OUT_EN + port * 4, 0x0);
+	REG_WR(sc, NIG_REG_BMAC0_REGS_OUT_EN + port * 4, 0x0);
 
 	vars->mac_type = ELINK_MAC_TYPE_EMAC;
 	return ELINK_STATUS_OK;
@@ -2137,15 +2096,6 @@ static elink_status_t elink_bmac1_enable(struct elink_params *params,
 	wb_data[1] = 0;
 	REG_WR_DMAE(sc, bmac_addr + BIGMAC_REGISTER_RX_LLFC_MSG_FLDS,
 		    wb_data, 2);
-#ifdef ELINK_INCLUDE_EMUL
-	/* Fix for emulation */
-	if (CHIP_REV_IS_EMUL(sc)) {
-		wb_data[0] = 0xf000;
-		wb_data[1] = 0;
-		REG_WR_DMAE(sc, bmac_addr + BIGMAC_REGISTER_TX_PAUSE_THRESHOLD,
-			    wb_data, 2);
-	}
-#endif
 
 	return ELINK_STATUS_OK;
 }
@@ -5922,11 +5872,6 @@ elink_status_t elink_set_led(struct elink_params *params,
 							  params, mode);
 		}
 	}
-#ifdef ELINK_INCLUDE_EMUL
-	if (params->feature_config_flags &
-	    ELINK_FEATURE_CONFIG_EMUL_DISABLE_EMAC)
-		return rc;
-#endif
 
 	switch (mode) {
 	case ELINK_LED_MODE_FRONT_PANEL_OFF:
@@ -11671,10 +11616,7 @@ elink_status_t elink_phy_probe(struct elink_params * params)
 	struct elink_phy *phy;
 	params->num_phys = 0;
 	PMD_DRV_LOG(DEBUG, "Begin phy probe");
-#ifdef ELINK_INCLUDE_EMUL
-	if (CHIP_REV_IS_EMUL(sc))
-		return ELINK_STATUS_OK;
-#endif
+
 	phy_config_swapped = params->multi_phy_config &
 	    PORT_HW_CFG_PHY_SWAPPED_ENABLED;
 
@@ -11739,182 +11681,6 @@ elink_status_t elink_phy_probe(struct elink_params * params)
 	return ELINK_STATUS_OK;
 }
 
-#ifdef ELINK_INCLUDE_EMUL
-static elink_status_t elink_init_e3_emul_mac(struct elink_params *params,
-					     struct elink_vars *vars)
-{
-	struct bnx2x_softc *sc = params->sc;
-	vars->line_speed = params->req_line_speed[0];
-	/* In case link speed is auto, set speed the highest as possible */
-	if (params->req_line_speed[0] == ELINK_SPEED_AUTO_NEG) {
-		if (params->feature_config_flags &
-		    ELINK_FEATURE_CONFIG_EMUL_DISABLE_XMAC)
-			vars->line_speed = ELINK_SPEED_2500;
-		else if (elink_is_4_port_mode(sc))
-			vars->line_speed = ELINK_SPEED_10000;
-		else
-			vars->line_speed = ELINK_SPEED_20000;
-	}
-	if (vars->line_speed < ELINK_SPEED_10000) {
-		if ((params->feature_config_flags &
-		     ELINK_FEATURE_CONFIG_EMUL_DISABLE_UMAC)) {
-			PMD_DRV_LOG(DEBUG, "Invalid line speed %d while UMAC is"
-				    " disabled!", params->req_line_speed[0]);
-			return ELINK_STATUS_ERROR;
-		}
-		switch (vars->line_speed) {
-		case ELINK_SPEED_10:
-			vars->link_status = ELINK_LINK_10TFD;
-			break;
-		case ELINK_SPEED_100:
-			vars->link_status = ELINK_LINK_100TXFD;
-			break;
-		case ELINK_SPEED_1000:
-			vars->link_status = ELINK_LINK_1000TFD;
-			break;
-		case ELINK_SPEED_2500:
-			vars->link_status = ELINK_LINK_2500TFD;
-			break;
-		default:
-			PMD_DRV_LOG(DEBUG, "Invalid line speed %d for UMAC",
-				    vars->line_speed);
-			return ELINK_STATUS_ERROR;
-		}
-		vars->link_status |= LINK_STATUS_LINK_UP;
-
-		if (params->loopback_mode == ELINK_LOOPBACK_UMAC)
-			elink_umac_enable(params, vars, 1);
-		else
-			elink_umac_enable(params, vars, 0);
-	} else {
-		/* Link speed >= 10000 requires XMAC enabled */
-		if (params->feature_config_flags &
-		    ELINK_FEATURE_CONFIG_EMUL_DISABLE_XMAC) {
-			PMD_DRV_LOG(DEBUG, "Invalid line speed %d while XMAC is"
-				    " disabled!", params->req_line_speed[0]);
-			return ELINK_STATUS_ERROR;
-		}
-		/* Check link speed */
-		switch (vars->line_speed) {
-		case ELINK_SPEED_10000:
-			vars->link_status = ELINK_LINK_10GTFD;
-			break;
-		case ELINK_SPEED_20000:
-			vars->link_status = ELINK_LINK_20GTFD;
-			break;
-		default:
-			PMD_DRV_LOG(DEBUG, "Invalid line speed %d for XMAC",
-				    vars->line_speed);
-			return ELINK_STATUS_ERROR;
-		}
-		vars->link_status |= LINK_STATUS_LINK_UP;
-		if (params->loopback_mode == ELINK_LOOPBACK_XMAC)
-			elink_xmac_enable(params, vars, 1);
-		else
-			elink_xmac_enable(params, vars, 0);
-	}
-	return ELINK_STATUS_OK;
-}
-
-static elink_status_t elink_init_emul(struct elink_params *params,
-				      struct elink_vars *vars)
-{
-	struct bnx2x_softc *sc = params->sc;
-	if (CHIP_IS_E3(sc)) {
-		if (elink_init_e3_emul_mac(params, vars) != ELINK_STATUS_OK)
-			return ELINK_STATUS_ERROR;
-	} else {
-		if (params->feature_config_flags &
-		    ELINK_FEATURE_CONFIG_EMUL_DISABLE_BMAC) {
-			vars->line_speed = ELINK_SPEED_1000;
-			vars->link_status = (LINK_STATUS_LINK_UP |
-					     ELINK_LINK_1000XFD);
-			if (params->loopback_mode == ELINK_LOOPBACK_EMAC)
-				elink_emac_enable(params, vars, 1);
-			else
-				elink_emac_enable(params, vars, 0);
-		} else {
-			vars->line_speed = ELINK_SPEED_10000;
-			vars->link_status = (LINK_STATUS_LINK_UP |
-					     ELINK_LINK_10GTFD);
-			if (params->loopback_mode == ELINK_LOOPBACK_BMAC)
-				elink_bmac_enable(params, vars, 1, 1);
-			else
-				elink_bmac_enable(params, vars, 0, 1);
-		}
-	}
-	vars->link_up = 1;
-	vars->duplex = DUPLEX_FULL;
-	vars->flow_ctrl = ELINK_FLOW_CTRL_NONE;
-
-	if (CHIP_IS_E1x(sc))
-		elink_pbf_update(params, vars->flow_ctrl, vars->line_speed);
-	/* Disable drain */
-	REG_WR(sc, NIG_REG_EGRESS_DRAIN0_MODE + params->port * 4, 0);
-
-	/* update shared memory */
-	elink_update_mng(params, vars->link_status);
-	return ELINK_STATUS_OK;
-}
-#endif
-#ifdef ELINK_INCLUDE_FPGA
-static elink_status_t elink_init_fpga(struct elink_params *params,
-				      struct elink_vars *vars)
-{
-	/* Enable on E1.5 FPGA */
-	struct bnx2x_softc *sc = params->sc;
-	vars->duplex = DUPLEX_FULL;
-	vars->flow_ctrl = ELINK_FLOW_CTRL_NONE;
-	vars->flow_ctrl = (ELINK_FLOW_CTRL_TX | ELINK_FLOW_CTRL_RX);
-	vars->link_status |= (LINK_STATUS_TX_FLOW_CONTROL_ENABLED |
-			      LINK_STATUS_RX_FLOW_CONTROL_ENABLED);
-	if (CHIP_IS_E3(sc)) {
-		vars->line_speed = params->req_line_speed[0];
-		switch (vars->line_speed) {
-		case ELINK_SPEED_AUTO_NEG:
-			vars->line_speed = ELINK_SPEED_2500;
-		case ELINK_SPEED_2500:
-			vars->link_status = ELINK_LINK_2500TFD;
-			break;
-		case ELINK_SPEED_1000:
-			vars->link_status = ELINK_LINK_1000XFD;
-			break;
-		case ELINK_SPEED_100:
-			vars->link_status = ELINK_LINK_100TXFD;
-			break;
-		case ELINK_SPEED_10:
-			vars->link_status = ELINK_LINK_10TFD;
-			break;
-		default:
-			PMD_DRV_LOG(DEBUG, "Invalid link speed %d",
-				    params->req_line_speed[0]);
-			return ELINK_STATUS_ERROR;
-		}
-		vars->link_status |= LINK_STATUS_LINK_UP;
-		if (params->loopback_mode == ELINK_LOOPBACK_UMAC)
-			elink_umac_enable(params, vars, 1);
-		else
-			elink_umac_enable(params, vars, 0);
-	} else {
-		vars->line_speed = ELINK_SPEED_10000;
-		vars->link_status = (LINK_STATUS_LINK_UP | ELINK_LINK_10GTFD);
-		if (params->loopback_mode == ELINK_LOOPBACK_EMAC)
-			elink_emac_enable(params, vars, 1);
-		else
-			elink_emac_enable(params, vars, 0);
-	}
-	vars->link_up = 1;
-
-	if (CHIP_IS_E1x(sc))
-		elink_pbf_update(params, vars->flow_ctrl, vars->line_speed);
-	/* Disable drain */
-	REG_WR(sc, NIG_REG_EGRESS_DRAIN0_MODE + params->port * 4, 0);
-
-	/* Update shared memory */
-	elink_update_mng(params, vars->link_status);
-	return ELINK_STATUS_OK;
-}
-#endif
 static void elink_init_bmac_loopback(struct elink_params *params,
 				     struct elink_vars *vars)
 {
@@ -12236,12 +12002,8 @@ elink_status_t elink_phy_init(struct elink_params *params,
 			ELINK_NIG_MASK_XGXS0_LINK10G |
 			ELINK_NIG_MASK_SERDES0_LINK_STATUS |
 			ELINK_NIG_MASK_MI_INT));
-#ifdef ELINK_INCLUDE_EMUL
-	if (!(params->feature_config_flags &
-	      ELINK_FEATURE_CONFIG_EMUL_DISABLE_EMAC))
-#endif
 
-		elink_emac_init(params);
+	elink_emac_init(params);
 
 	if (params->feature_config_flags & ELINK_FEATURE_CONFIG_PFC_ENABLED)
 		vars->link_status |= LINK_STATUS_PFC_ENABLED;
@@ -12253,45 +12015,36 @@ elink_status_t elink_phy_init(struct elink_params *params,
 	set_phy_vars(params, vars);
 
 	PMD_DRV_LOG(DEBUG, "Num of phys on board: %d", params->num_phys);
-#ifdef ELINK_INCLUDE_FPGA
-	if (CHIP_REV_IS_FPGA(sc)) {
-		return elink_init_fpga(params, vars);
-	} else
-#endif
-#ifdef ELINK_INCLUDE_EMUL
-	if (CHIP_REV_IS_EMUL(sc)) {
-		return elink_init_emul(params, vars);
-	} else
-#endif
-		switch (params->loopback_mode) {
-		case ELINK_LOOPBACK_BMAC:
-			elink_init_bmac_loopback(params, vars);
-			break;
-		case ELINK_LOOPBACK_EMAC:
-			elink_init_emac_loopback(params, vars);
-			break;
-		case ELINK_LOOPBACK_XMAC:
-			elink_init_xmac_loopback(params, vars);
-			break;
-		case ELINK_LOOPBACK_UMAC:
-			elink_init_umac_loopback(params, vars);
-			break;
-		case ELINK_LOOPBACK_XGXS:
-		case ELINK_LOOPBACK_EXT_PHY:
-			elink_init_xgxs_loopback(params, vars);
-			break;
-		default:
-			if (!CHIP_IS_E3(sc)) {
-				if (params->switch_cfg == ELINK_SWITCH_CFG_10G)
-					elink_xgxs_deassert(params);
-				else
-					elink_serdes_deassert(sc, params->port);
-			}
-			elink_link_initialize(params, vars);
-			DELAY(1000 * 30);
-			elink_link_int_enable(params);
-			break;
+
+	switch (params->loopback_mode) {
+	case ELINK_LOOPBACK_BMAC:
+		elink_init_bmac_loopback(params, vars);
+		break;
+	case ELINK_LOOPBACK_EMAC:
+		elink_init_emac_loopback(params, vars);
+		break;
+	case ELINK_LOOPBACK_XMAC:
+		elink_init_xmac_loopback(params, vars);
+		break;
+	case ELINK_LOOPBACK_UMAC:
+		elink_init_umac_loopback(params, vars);
+		break;
+	case ELINK_LOOPBACK_XGXS:
+	case ELINK_LOOPBACK_EXT_PHY:
+		elink_init_xgxs_loopback(params, vars);
+		break;
+	default:
+		if (!CHIP_IS_E3(sc)) {
+			if (params->switch_cfg == ELINK_SWITCH_CFG_10G)
+				elink_xgxs_deassert(params);
+			else
+				elink_serdes_deassert(sc, params->port);
 		}
+		elink_link_initialize(params, vars);
+		DELAY(1000 * 30);
+		elink_link_int_enable(params);
+		break;
+	}
 	elink_update_mng(params, vars->link_status);
 
 	elink_update_mng_eee(params, vars->eee_status);
@@ -12325,22 +12078,12 @@ static elink_status_t elink_link_reset(struct elink_params *params,
 		REG_WR(sc, NIG_REG_BMAC0_OUT_EN + port * 4, 0);
 		REG_WR(sc, NIG_REG_EGRESS_EMAC0_OUT_EN + port * 4, 0);
 	}
-#ifdef ELINK_INCLUDE_EMUL
-	/* Stop BigMac rx */
-	if (!(params->feature_config_flags &
-	      ELINK_FEATURE_CONFIG_EMUL_DISABLE_BMAC))
-#endif
-		if (!CHIP_IS_E3(sc))
-			elink_set_bmac_rx(sc, port, 0);
-#ifdef ELINK_INCLUDE_EMUL
-	/* Stop XMAC/UMAC rx */
-	if (!(params->feature_config_flags &
-	      ELINK_FEATURE_CONFIG_EMUL_DISABLE_XMAC))
-#endif
-		if (CHIP_IS_E3(sc) && !CHIP_REV_IS_FPGA(sc)) {
-			elink_set_xmac_rxtx(params, 0);
-			elink_set_umac_rxtx(params, 0);
-		}
+	if (!CHIP_IS_E3(sc))
+		elink_set_bmac_rx(sc, port, 0);
+	if (CHIP_IS_E3(sc) && !CHIP_REV_IS_FPGA(sc)) {
+		elink_set_xmac_rxtx(params, 0);
+		elink_set_umac_rxtx(params, 0);
+	}
 	/* Disable emac */
 	if (!CHIP_IS_E3(sc))
 		REG_WR(sc, NIG_REG_NIG_EMAC0_EN + port * 4, 0);
@@ -12376,14 +12119,11 @@ static elink_status_t elink_link_reset(struct elink_params *params,
 		elink_bits_dis(sc, NIG_REG_LATCH_BC_0 + port * 4,
 			       1 << ELINK_NIG_LATCH_BC_ENABLE_MI_INT);
 	}
-#if defined(ELINK_INCLUDE_EMUL) || defined(ELINK_INCLUDE_FPGA)
-	if (!CHIP_REV_IS_SLOW(sc))
-#endif
-		if (params->phy[ELINK_INT_PHY].link_reset)
-			params->phy[ELINK_INT_PHY].link_reset(&params->
-							      phy
-							      [ELINK_INT_PHY],
-							      params);
+	if (params->phy[ELINK_INT_PHY].link_reset)
+		params->phy[ELINK_INT_PHY].link_reset(&params->
+						      phy
+						      [ELINK_INT_PHY],
+						      params);
 
 	/* Disable nig ingress interface */
 	if (!CHIP_IS_E3(sc)) {
@@ -12868,10 +12608,6 @@ elink_status_t elink_common_init_phy(struct bnx2x_softc * sc,
 	uint32_t phy_ver, val;
 	uint8_t phy_index = 0;
 	uint32_t ext_phy_type, ext_phy_config;
-#if defined(ELINK_INCLUDE_EMUL) || defined(ELINK_INCLUDE_FPGA)
-	if (CHIP_REV_IS_EMUL(sc) || CHIP_REV_IS_FPGA(sc))
-		return ELINK_STATUS_OK;
-#endif
 
 	elink_set_mdio_clk(sc, GRCBASE_EMAC0);
 	elink_set_mdio_clk(sc, GRCBASE_EMAC1);
diff --git a/drivers/net/bnx2x/elink.h b/drivers/net/bnx2x/elink.h
index c4f886a..9401b7c 100644
--- a/drivers/net/bnx2x/elink.h
+++ b/drivers/net/bnx2x/elink.h
@@ -359,10 +359,6 @@ struct elink_params {
 #define ELINK_FEATURE_CONFIG_PFC_ENABLED			(1<<1)
 #define ELINK_FEATURE_CONFIG_BC_SUPPORTS_OPT_MDL_VRFY		(1<<2)
 #define ELINK_FEATURE_CONFIG_BC_SUPPORTS_DUAL_PHY_OPT_MDL_VRFY	(1<<3)
-#define ELINK_FEATURE_CONFIG_EMUL_DISABLE_EMAC			(1<<4)
-#define ELINK_FEATURE_CONFIG_EMUL_DISABLE_BMAC			(1<<5)
-#define ELINK_FEATURE_CONFIG_EMUL_DISABLE_UMAC			(1<<6)
-#define ELINK_FEATURE_CONFIG_EMUL_DISABLE_XMAC			(1<<7)
 #define ELINK_FEATURE_CONFIG_BC_SUPPORTS_AFEX			(1<<8)
 #define ELINK_FEATURE_CONFIG_AUTOGREEEN_ENABLED		(1<<9)
 #define ELINK_FEATURE_CONFIG_BC_SUPPORTS_SFP_TX_DISABLED	(1<<10)
-- 
2.5.5

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [dpdk-dev] [PATCH 03/10] bnx2x: Remove delay during device startup
  2016-07-12 13:38 [dpdk-dev] [PATCH 02/10] bnx2x: Remove unused preprocessor symbols and code Chas Williams
@ 2016-07-12 13:38 ` Chas Williams
  2016-07-12 13:38 ` [dpdk-dev] [PATCH 04/10] bnx2x: Remove unused RX queue code Chas Williams
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Chas Williams @ 2016-07-12 13:38 UTC (permalink / raw)
  To: dev; +Cc: harish.patil, Chas Williams

This 2.5s delay doesn't seem to serve any purpose other than a being a
pause after logging the device configuration.

Fixes: 540a211084a7 ("bnx2x: driver core")

Signed-off-by: Chas Williams <3chas3@gmail.com>
---
 drivers/net/bnx2x/bnx2x_ethdev.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/net/bnx2x/bnx2x_ethdev.c b/drivers/net/bnx2x/bnx2x_ethdev.c
index 071b44f..047b782 100644
--- a/drivers/net/bnx2x/bnx2x_ethdev.c
+++ b/drivers/net/bnx2x/bnx2x_ethdev.c
@@ -154,8 +154,6 @@ bnx2x_dev_start(struct rte_eth_dev *dev)
 	/* Print important adapter info for the user. */
 	bnx2x_print_adapter_info(sc);
 
-	DELAY_MS(2500);
-
 	return ret;
 }
 
-- 
2.5.5

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [dpdk-dev] [PATCH 04/10] bnx2x: Remove unused RX queue code
  2016-07-12 13:38 [dpdk-dev] [PATCH 02/10] bnx2x: Remove unused preprocessor symbols and code Chas Williams
  2016-07-12 13:38 ` [dpdk-dev] [PATCH 03/10] bnx2x: Remove delay during device startup Chas Williams
@ 2016-07-12 13:38 ` Chas Williams
  2016-07-12 13:38 ` [dpdk-dev] [PATCH 05/10] bnx2x: Restrict RX mask flags sent to the PF Chas Williams
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Chas Williams @ 2016-07-12 13:38 UTC (permalink / raw)
  To: dev; +Cc: harish.patil, Chas Williams

Fixes: 540a211084a7 ("bnx2x: driver core")

Signed-off-by: Chas Williams <3chas3@gmail.com>
---
 drivers/net/bnx2x/bnx2x_rxtx.c | 13 +++----------
 drivers/net/bnx2x/bnx2x_rxtx.h |  6 ------
 2 files changed, 3 insertions(+), 16 deletions(-)

diff --git a/drivers/net/bnx2x/bnx2x_rxtx.c b/drivers/net/bnx2x/bnx2x_rxtx.c
index 55d2bd7..2bd48d9 100644
--- a/drivers/net/bnx2x/bnx2x_rxtx.c
+++ b/drivers/net/bnx2x/bnx2x_rxtx.c
@@ -59,7 +59,7 @@ bnx2x_dev_rx_queue_setup(struct rte_eth_dev *dev,
 		       uint16_t queue_idx,
 		       uint16_t nb_desc,
 		       unsigned int socket_id,
-		       const struct rte_eth_rxconf *rx_conf,
+		       __rte_unused const struct rte_eth_rxconf *rx_conf,
 		       struct rte_mempool *mp)
 {
 	uint16_t j, idx;
@@ -84,7 +84,6 @@ bnx2x_dev_rx_queue_setup(struct rte_eth_dev *dev,
 	rxq->mb_pool = mp;
 	rxq->queue_id = queue_idx;
 	rxq->port_id = dev->data->port_id;
-	rxq->crc_len = (uint8_t)((dev->data->dev_conf.rxmode.hw_strip_crc) ? 0 : ETHER_CRC_LEN);
 
 	rxq->nb_rx_pages = 1;
 	while (USABLE_RX_BD(rxq) < nb_desc)
@@ -94,13 +93,9 @@ bnx2x_dev_rx_queue_setup(struct rte_eth_dev *dev,
 	sc->rx_ring_size = USABLE_RX_BD(rxq);
 	rxq->nb_cq_pages = RCQ_BD_PAGES(rxq);
 
-	rxq->rx_free_thresh = rx_conf->rx_free_thresh ?
-		rx_conf->rx_free_thresh : DEFAULT_RX_FREE_THRESH;
-
-	PMD_INIT_LOG(DEBUG, "fp[%02d] req_bd=%u, thresh=%u, usable_bd=%lu, "
+	PMD_INIT_LOG(DEBUG, "fp[%02d] req_bd=%u, usable_bd=%lu, "
 		       "total_bd=%lu, rx_pages=%u, cq_pages=%u",
-		       queue_idx, nb_desc, rxq->rx_free_thresh,
-		       (unsigned long)USABLE_RX_BD(rxq),
+		       queue_idx, nb_desc, (unsigned long)USABLE_RX_BD(rxq),
 		       (unsigned long)TOTAL_RX_BD(rxq), rxq->nb_rx_pages,
 		       rxq->nb_cq_pages);
 
@@ -135,7 +130,6 @@ bnx2x_dev_rx_queue_setup(struct rte_eth_dev *dev,
 	}
 
 	/* Initialize software ring entries */
-	rxq->rx_mbuf_alloc = 0;
 	for (idx = 0; idx < rxq->nb_rx_desc; idx = NEXT_RX_BD(idx)) {
 		mbuf = rte_mbuf_raw_alloc(mp);
 		if (NULL == mbuf) {
@@ -146,7 +140,6 @@ bnx2x_dev_rx_queue_setup(struct rte_eth_dev *dev,
 		}
 		rxq->sw_ring[idx] = mbuf;
 		rxq->rx_ring[idx] = mbuf->buf_physaddr;
-		rxq->rx_mbuf_alloc++;
 	}
 	rxq->pkt_first_seg = NULL;
 	rxq->pkt_last_seg = NULL;
diff --git a/drivers/net/bnx2x/bnx2x_rxtx.h b/drivers/net/bnx2x/bnx2x_rxtx.h
index ccb22fc..dd251aa 100644
--- a/drivers/net/bnx2x/bnx2x_rxtx.h
+++ b/drivers/net/bnx2x/bnx2x_rxtx.h
@@ -11,8 +11,6 @@
 #ifndef _BNX2X_RXTX_H_
 #define _BNX2X_RXTX_H_
 
-
-#define DEFAULT_RX_FREE_THRESH   0
 #define DEFAULT_TX_FREE_THRESH   512
 #define RTE_PMD_BNX2X_TX_MAX_BURST 1
 
@@ -42,13 +40,9 @@ struct bnx2x_rx_queue {
 	uint16_t                   rx_bd_tail;           /**< Index of last rx bd. */
 	uint16_t                   rx_cq_head;           /**< Index of current rcq bd. */
 	uint16_t                   rx_cq_tail;           /**< Index of last rcq bd. */
-	uint16_t                   nb_rx_hold;           /**< number of held free RX desc. */
-	uint16_t                   rx_free_thresh;       /**< max free RX desc to hold. */
 	uint16_t                   queue_id;             /**< RX queue index. */
 	uint8_t                    port_id;              /**< Device port identifier. */
-	uint8_t                    crc_len;              /**< 0 if CRC stripped, 4 otherwise. */
 	struct bnx2x_softc           *sc;                  /**< Ptr to dev_private data. */
-	uint64_t                   rx_mbuf_alloc;        /**< Number of allocated mbufs. */
 };
 
 /**
-- 
2.5.5

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [dpdk-dev] [PATCH 05/10] bnx2x: Restrict RX mask flags sent to the PF
  2016-07-12 13:38 [dpdk-dev] [PATCH 02/10] bnx2x: Remove unused preprocessor symbols and code Chas Williams
  2016-07-12 13:38 ` [dpdk-dev] [PATCH 03/10] bnx2x: Remove delay during device startup Chas Williams
  2016-07-12 13:38 ` [dpdk-dev] [PATCH 04/10] bnx2x: Remove unused RX queue code Chas Williams
@ 2016-07-12 13:38 ` Chas Williams
  2016-07-12 13:38 ` [dpdk-dev] [PATCH 06/10] bnx2x: Replace macro with static function Chas Williams
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Chas Williams @ 2016-07-12 13:38 UTC (permalink / raw)
  To: dev; +Cc: harish.patil, Chas Williams

Don't use bnx2x_fill_accept_flags() to fill the RX mask in the VF
since the PF only handles a subset of the existing flags.  now,
bnx2x_fill_accept_flags() can be static.

Fixes: 540a211084a7 ("bnx2x: driver core")

Signed-off-by: Chas Williams <3chas3@gmail.com>
---
 drivers/net/bnx2x/bnx2x.c      |  6 +++---
 drivers/net/bnx2x/bnx2x.h      |  2 --
 drivers/net/bnx2x/bnx2x_vfpf.c | 23 +++++++++++++++++++++--
 drivers/net/bnx2x/bnx2x_vfpf.h |  7 +++++++
 4 files changed, 31 insertions(+), 7 deletions(-)

diff --git a/drivers/net/bnx2x/bnx2x.c b/drivers/net/bnx2x/bnx2x.c
index 7599e9c..6ca6ede 100644
--- a/drivers/net/bnx2x/bnx2x.c
+++ b/drivers/net/bnx2x/bnx2x.c
@@ -1396,10 +1396,10 @@ bnx2x_del_all_macs(struct bnx2x_softc *sc, struct ecore_vlan_mac_obj *mac_obj,
 	return rc;
 }
 
-int
+static int
 bnx2x_fill_accept_flags(struct bnx2x_softc *sc, uint32_t rx_mode,
-		      unsigned long *rx_accept_flags,
-		      unsigned long *tx_accept_flags)
+			unsigned long *rx_accept_flags,
+			unsigned long *tx_accept_flags)
 {
 	/* Clear the flags first */
 	*rx_accept_flags = 0;
diff --git a/drivers/net/bnx2x/bnx2x.h b/drivers/net/bnx2x/bnx2x.h
index 852ec94..2746562 100644
--- a/drivers/net/bnx2x/bnx2x.h
+++ b/drivers/net/bnx2x/bnx2x.h
@@ -1878,8 +1878,6 @@ int bnx2x_vf_setup_queue(struct bnx2x_softc *sc, struct bnx2x_fastpath *fp,
 	int leading);
 void bnx2x_free_hsi_mem(struct bnx2x_softc *sc);
 int bnx2x_vf_set_rx_mode(struct bnx2x_softc *sc);
-int bnx2x_fill_accept_flags(struct bnx2x_softc *sc, uint32_t rx_mode,
-	unsigned long *rx_accept_flags, unsigned long *tx_accept_flags);
 int bnx2x_check_bull(struct bnx2x_softc *sc);
 
 //#define BNX2X_PULSE
diff --git a/drivers/net/bnx2x/bnx2x_vfpf.c b/drivers/net/bnx2x/bnx2x_vfpf.c
index 14b1d10..1b4899f 100644
--- a/drivers/net/bnx2x/bnx2x_vfpf.c
+++ b/drivers/net/bnx2x/bnx2x_vfpf.c
@@ -575,7 +575,6 @@ bnx2x_vf_set_rx_mode(struct bnx2x_softc *sc)
 {
 	struct vf_set_q_filters_tlv *query;
 	struct vf_common_reply_tlv *reply = &sc->vf2pf_mbox->resp.common_reply;
-	unsigned long tx_mask;
 
 	query = &sc->vf2pf_mbox->query[0].set_q_filters;
 	bnx2x_init_first_tlv(sc, &query->first_tlv, BNX2X_VF_TLV_SET_Q_FILTERS,
@@ -584,7 +583,27 @@ bnx2x_vf_set_rx_mode(struct bnx2x_softc *sc)
 	query->vf_qid = 0;
 	query->flags = BNX2X_VF_RX_MASK_CHANGED;
 
-	if (bnx2x_fill_accept_flags(sc, sc->rx_mode, &query->rx_mask, &tx_mask)) {
+	switch (sc->rx_mode) {
+	case BNX2X_RX_MODE_NONE: /* no Rx */
+		query->rx_mask = VFPF_RX_MASK_ACCEPT_NONE;
+		break;
+	case BNX2X_RX_MODE_NORMAL:
+		query->rx_mask = VFPF_RX_MASK_ACCEPT_MATCHED_MULTICAST;
+		query->rx_mask |= VFPF_RX_MASK_ACCEPT_MATCHED_UNICAST;
+		query->rx_mask |= VFPF_RX_MASK_ACCEPT_BROADCAST;
+		break;
+	case BNX2X_RX_MODE_ALLMULTI:
+		query->rx_mask = VFPF_RX_MASK_ACCEPT_ALL_MULTICAST;
+		query->rx_mask |= VFPF_RX_MASK_ACCEPT_MATCHED_UNICAST;
+		query->rx_mask |= VFPF_RX_MASK_ACCEPT_BROADCAST;
+		break;
+	case BNX2X_RX_MODE_PROMISC:
+		query->rx_mask = VFPF_RX_MASK_ACCEPT_ALL_UNICAST;
+		query->rx_mask |= VFPF_RX_MASK_ACCEPT_ALL_MULTICAST;
+		query->rx_mask |= VFPF_RX_MASK_ACCEPT_BROADCAST;
+		break;
+	default:
+		PMD_DRV_LOG(ERR, "BAD rx mode (%d)", mode);
 		return -EINVAL;
 	}
 
diff --git a/drivers/net/bnx2x/bnx2x_vfpf.h b/drivers/net/bnx2x/bnx2x_vfpf.h
index 966240c..62e1d60 100644
--- a/drivers/net/bnx2x/bnx2x_vfpf.h
+++ b/drivers/net/bnx2x/bnx2x_vfpf.h
@@ -40,6 +40,13 @@ struct vf_resource_query {
 
 #define TLV_BUFFER_SIZE			1024
 
+#define VFPF_RX_MASK_ACCEPT_NONE		0x00000000
+#define VFPF_RX_MASK_ACCEPT_MATCHED_UNICAST	0x00000001
+#define VFPF_RX_MASK_ACCEPT_MATCHED_MULTICAST	0x00000002
+#define VFPF_RX_MASK_ACCEPT_ALL_UNICAST		0x00000004
+#define VFPF_RX_MASK_ACCEPT_ALL_MULTICAST	0x00000008
+#define VFPF_RX_MASK_ACCEPT_BROADCAST		0x00000010
+
 /* general tlv header (used for both vf->pf request and pf->vf response) */
 struct channel_tlv {
 	uint16_t type;
-- 
2.5.5

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [dpdk-dev] [PATCH 06/10] bnx2x: Replace macro with static function
  2016-07-12 13:38 [dpdk-dev] [PATCH 02/10] bnx2x: Remove unused preprocessor symbols and code Chas Williams
                   ` (2 preceding siblings ...)
  2016-07-12 13:38 ` [dpdk-dev] [PATCH 05/10] bnx2x: Restrict RX mask flags sent to the PF Chas Williams
@ 2016-07-12 13:38 ` Chas Williams
  2016-07-12 13:38 ` [dpdk-dev] [PATCH 07/10] bnx2x: Serialize access to pf2vf mailbox Chas Williams
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Chas Williams @ 2016-07-12 13:38 UTC (permalink / raw)
  To: dev; +Cc: harish.patil, Chas Williams

Replace BNX2X_TLV_APPEND() with the clearer and safer bnx2x_add_tlv().
bnx2x_add_tlv() was previously prototyped at some point but can be static.

Fixes: 540a211084a7 ("bnx2x: driver core")

Signed-off-by: Chas Williams <3chas3@gmail.com>
---
 drivers/net/bnx2x/bnx2x_vfpf.c | 80 +++++++++++++++++++++++++-----------------
 drivers/net/bnx2x/bnx2x_vfpf.h | 10 ++----
 2 files changed, 50 insertions(+), 40 deletions(-)

diff --git a/drivers/net/bnx2x/bnx2x_vfpf.c b/drivers/net/bnx2x/bnx2x_vfpf.c
index 1b4899f..46bf739 100644
--- a/drivers/net/bnx2x/bnx2x_vfpf.c
+++ b/drivers/net/bnx2x/bnx2x_vfpf.c
@@ -64,25 +64,32 @@ bnx2x_check_bull(struct bnx2x_softc *sc)
 	return TRUE;
 }
 
-/* add tlv to a buffer */
-#define BNX2X_TLV_APPEND(_tlvs, _offset, _type, _length) \
-	((struct vf_first_tlv *)((unsigned long)_tlvs + _offset))->type   = _type; \
-	((struct vf_first_tlv *)((unsigned long)_tlvs + _offset))->length = _length
+/* place a given tlv on the tlv buffer at a given offset */
+static void
+bnx2x_add_tlv(__rte_unused struct bnx2x_softc *sc, void *tlvs_list,
+	      uint16_t offset, uint16_t type, uint16_t length)
+{
+	struct channel_tlv *tl = (struct channel_tlv *)
+					((unsigned long)tlvs_list + offset);
+
+	tl->type = type;
+	tl->length = length;
+}
 
 /* Initiliaze header of the first tlv and clear mailbox*/
 static void
-bnx2x_init_first_tlv(struct bnx2x_softc *sc, struct vf_first_tlv *tlv,
-	uint16_t type, uint16_t len)
+bnx2x_init_first_tlv(struct bnx2x_softc *sc, struct vf_first_tlv *first_tlv,
+	uint16_t type, uint16_t length)
 {
 	struct bnx2x_vf_mbx_msg *mbox = sc->vf2pf_mbox;
 	PMD_DRV_LOG(DEBUG, "Preparing %d tlv for sending", type);
 
 	memset(mbox, 0, sizeof(struct bnx2x_vf_mbx_msg));
 
-	BNX2X_TLV_APPEND(tlv, 0, type, len);
+	bnx2x_add_tlv(sc, &first_tlv->tl, 0, type, length);
 
 	/* Initialize header of the first tlv */
-	tlv->reply_offset = sizeof(mbox->query);
+	first_tlv->reply_offset = sizeof(mbox->query);
 }
 
 #define BNX2X_VF_CMD_ADDR_LO PXP_VF_ADDR_CSDM_GLOBAL_START
@@ -256,14 +263,14 @@ int bnx2x_vf_get_resources(struct bnx2x_softc *sc, uint8_t tx_count, uint8_t rx_
 	acq->bulletin_addr = sc->pf2vf_bulletin_mapping.paddr;
 
 	/* Request physical port identifier */
-	BNX2X_TLV_APPEND(acq, acq->first_tlv.length,
-			 BNX2X_VF_TLV_PHYS_PORT_ID,
-			 sizeof(struct channel_tlv));
+	bnx2x_add_tlv(sc, acq, acq->first_tlv.tl.length,
+		      BNX2X_VF_TLV_PHYS_PORT_ID,
+		      sizeof(struct channel_tlv));
 
-	BNX2X_TLV_APPEND(acq,
-			 (acq->first_tlv.length + sizeof(struct channel_tlv)),
-			 BNX2X_VF_TLV_LIST_END,
-			 sizeof(struct channel_list_end_tlv));
+	bnx2x_add_tlv(sc, acq,
+		      (acq->first_tlv.tl.length + sizeof(struct channel_tlv)),
+		      BNX2X_VF_TLV_LIST_END,
+		      sizeof(struct channel_list_end_tlv));
 
 	/* requesting the resources in loop */
 	obtain_status = bnx2x_loop_obtain_resources(sc);
@@ -315,8 +322,9 @@ bnx2x_vf_close(struct bnx2x_softc *sc)
 				sizeof(*query));
 
 		query->vf_id = vf_id;
-		BNX2X_TLV_APPEND(query, query->first_tlv.length, BNX2X_VF_TLV_LIST_END,
-				sizeof(struct channel_list_end_tlv));
+		bnx2x_add_tlv(sc, query, query->first_tlv.tl.length,
+			      BNX2X_VF_TLV_LIST_END,
+			      sizeof(struct channel_list_end_tlv));
 
 		bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
 		if (reply->status != BNX2X_VF_STATUS_SUCCESS)
@@ -344,8 +352,9 @@ bnx2x_vf_init(struct bnx2x_softc *sc)
 	query->stats_addr = sc->fw_stats_data_mapping +
 		offsetof(struct bnx2x_fw_stats_data, queue_stats);
 
-	BNX2X_TLV_APPEND(query, query->first_tlv.length, BNX2X_VF_TLV_LIST_END,
-			sizeof(struct channel_list_end_tlv));
+	bnx2x_add_tlv(sc, query, query->first_tlv.tl.length,
+		      BNX2X_VF_TLV_LIST_END,
+		      sizeof(struct channel_list_end_tlv));
 
 	bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
 	if (reply->status != BNX2X_VF_STATUS_SUCCESS) {
@@ -375,9 +384,10 @@ bnx2x_vf_unload(struct bnx2x_softc *sc)
 
 			query_op->vf_qid = i;
 
-			BNX2X_TLV_APPEND(query_op, query_op->first_tlv.length,
-					BNX2X_VF_TLV_LIST_END,
-					sizeof(struct channel_list_end_tlv));
+			bnx2x_add_tlv(sc, query_op,
+				      query_op->first_tlv.tl.length,
+				      BNX2X_VF_TLV_LIST_END,
+				      sizeof(struct channel_list_end_tlv));
 
 			bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
 			if (reply->status != BNX2X_VF_STATUS_SUCCESS)
@@ -393,9 +403,9 @@ bnx2x_vf_unload(struct bnx2x_softc *sc)
 
 		query->vf_id = vf_id;
 
-		BNX2X_TLV_APPEND(query, query->first_tlv.length,
-				BNX2X_VF_TLV_LIST_END,
-				sizeof(struct channel_list_end_tlv));
+		bnx2x_add_tlv(sc, query, query->first_tlv.tl.length,
+			      BNX2X_VF_TLV_LIST_END,
+			      sizeof(struct channel_list_end_tlv));
 
 		bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
 		if (reply->status != BNX2X_VF_STATUS_SUCCESS)
@@ -476,8 +486,9 @@ bnx2x_vf_setup_queue(struct bnx2x_softc *sc, struct bnx2x_fastpath *fp, int lead
 	bnx2x_vf_rx_q_prep(sc, fp, &query->rxq, flags);
 	bnx2x_vf_tx_q_prep(sc, fp, &query->txq, flags);
 
-	BNX2X_TLV_APPEND(query, query->first_tlv.length, BNX2X_VF_TLV_LIST_END,
-			sizeof(struct channel_list_end_tlv));
+	bnx2x_add_tlv(sc, query, query->first_tlv.tl.length,
+		      BNX2X_VF_TLV_LIST_END,
+		      sizeof(struct channel_list_end_tlv));
 
 	bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
 	if (reply->status != BNX2X_VF_STATUS_SUCCESS) {
@@ -510,8 +521,9 @@ bnx2x_vf_set_mac(struct bnx2x_softc *sc, int set)
 
 	rte_memcpy(query->filters[0].mac, sc->link_params.mac_addr, ETH_ALEN);
 
-	BNX2X_TLV_APPEND(query, query->first_tlv.length, BNX2X_VF_TLV_LIST_END,
-			sizeof(struct channel_list_end_tlv));
+	bnx2x_add_tlv(sc, query, query->first_tlv.tl.length,
+		      BNX2X_VF_TLV_LIST_END,
+		      sizeof(struct channel_list_end_tlv));
 
 	bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
 	reply = &sc->vf2pf_mbox->resp.common_reply;
@@ -549,8 +561,9 @@ bnx2x_vf_config_rss(struct bnx2x_softc *sc,
 			sizeof(*query));
 
 	/* add list termination tlv */
-	BNX2X_TLV_APPEND(query, query->first_tlv.length, BNX2X_VF_TLV_LIST_END,
-			sizeof(struct channel_list_end_tlv));
+	bnx2x_add_tlv(sc, query, query->first_tlv.tl.length,
+		      BNX2X_VF_TLV_LIST_END,
+		      sizeof(struct channel_list_end_tlv));
 
 	rte_memcpy(query->rss_key, params->rss_key, sizeof(params->rss_key));
 	query->rss_key_size = T_ETH_RSS_KEY;
@@ -607,8 +620,9 @@ bnx2x_vf_set_rx_mode(struct bnx2x_softc *sc)
 		return -EINVAL;
 	}
 
-	BNX2X_TLV_APPEND(query, query->first_tlv.length, BNX2X_VF_TLV_LIST_END,
-			sizeof(struct channel_list_end_tlv));
+	bnx2x_add_tlv(sc, query, query->first_tlv.tl.length,
+		      BNX2X_VF_TLV_LIST_END,
+		      sizeof(struct channel_list_end_tlv));
 
 	bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
 	if (reply->status != BNX2X_VF_STATUS_SUCCESS) {
diff --git a/drivers/net/bnx2x/bnx2x_vfpf.h b/drivers/net/bnx2x/bnx2x_vfpf.h
index 62e1d60..54efc40 100644
--- a/drivers/net/bnx2x/bnx2x_vfpf.h
+++ b/drivers/net/bnx2x/bnx2x_vfpf.h
@@ -54,8 +54,7 @@ struct channel_tlv {
 };
 
 struct vf_first_tlv {
-	uint16_t type;
-	uint16_t length;
+	struct channel_tlv tl;
 	uint32_t reply_offset;
 };
 
@@ -65,16 +64,14 @@ struct tlv_buffer_size {
 
 /* tlv struct for all PF replies except acquire */
 struct vf_common_reply_tlv {
-	uint16_t type;
-	uint16_t length;
+	struct channel_tlv tl;
 	uint8_t status;
 	uint8_t pad[3];
 };
 
 /* used to terminate and pad a tlv list */
 struct channel_list_end_tlv {
-	uint16_t type;
-	uint16_t length;
+	struct channel_tlv tl;
 	uint32_t pad;
 };
 
@@ -334,7 +331,6 @@ struct bnx2x_vf_mbx_msg {
 	union resp_tlvs resp;
 };
 
-void bnx2x_add_tlv(void *tlvs_list, uint16_t offset, uint16_t type, uint16_t length);
 int bnx2x_vf_set_mac(struct bnx2x_softc *sc, int set);
 int bnx2x_vf_config_rss(struct bnx2x_softc *sc, struct ecore_config_rss_params *params);
 
-- 
2.5.5

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [dpdk-dev] [PATCH 07/10] bnx2x: Serialize access to pf2vf mailbox
  2016-07-12 13:38 [dpdk-dev] [PATCH 02/10] bnx2x: Remove unused preprocessor symbols and code Chas Williams
                   ` (3 preceding siblings ...)
  2016-07-12 13:38 ` [dpdk-dev] [PATCH 06/10] bnx2x: Replace macro with static function Chas Williams
@ 2016-07-12 13:38 ` Chas Williams
  2016-07-12 13:38 ` [dpdk-dev] [PATCH 08/10] bnx2x: Check return codes during VF mailbox operation Chas Williams
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Chas Williams @ 2016-07-12 13:38 UTC (permalink / raw)
  To: dev; +Cc: harish.patil, Chas Williams

The pf2vf mailbox can only be used by one thread at a time.

Fixes: 540a211084a7 ("bnx2x: driver core")

Signed-off-by: Chas Williams <3chas3@gmail.com>
---
 drivers/net/bnx2x/bnx2x.h        |  12 +++--
 drivers/net/bnx2x/bnx2x_ethdev.c |   2 +
 drivers/net/bnx2x/bnx2x_vfpf.c   | 113 +++++++++++++++++++++++++++------------
 3 files changed, 88 insertions(+), 39 deletions(-)

diff --git a/drivers/net/bnx2x/bnx2x.h b/drivers/net/bnx2x/bnx2x.h
index 2746562..d0d5b65 100644
--- a/drivers/net/bnx2x/bnx2x.h
+++ b/drivers/net/bnx2x/bnx2x.h
@@ -17,6 +17,7 @@
 #define __BNX2X_H__
 
 #include <rte_byteorder.h>
+#include <rte_spinlock.h>
 
 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
 #ifndef __LITTLE_ENDIAN
@@ -1026,12 +1027,13 @@ struct bnx2x_softc {
 	struct bnx2x_mac_ops mac_ops;
 
 	/* structures for VF mbox/response/bulletin */
-	struct bnx2x_vf_mbx_msg	*vf2pf_mbox;
-	struct bnx2x_dma		vf2pf_mbox_mapping;
-	struct vf_acquire_resp_tlv acquire_resp;
+	struct bnx2x_vf_mbx_msg		*vf2pf_mbox;
+	struct bnx2x_dma		 vf2pf_mbox_mapping;
+	struct vf_acquire_resp_tlv	 acquire_resp;
 	struct bnx2x_vf_bulletin	*pf2vf_bulletin;
-	struct bnx2x_dma		pf2vf_bulletin_mapping;
-	struct bnx2x_vf_bulletin	old_bulletin;
+	struct bnx2x_dma		 pf2vf_bulletin_mapping;
+	struct bnx2x_vf_bulletin	 old_bulletin;
+	rte_spinlock_t			 vf2pf_lock;
 
 	int             media;
 
diff --git a/drivers/net/bnx2x/bnx2x_ethdev.c b/drivers/net/bnx2x/bnx2x_ethdev.c
index 047b782..88be036 100644
--- a/drivers/net/bnx2x/bnx2x_ethdev.c
+++ b/drivers/net/bnx2x/bnx2x_ethdev.c
@@ -460,6 +460,8 @@ bnx2x_common_dev_init(struct rte_eth_dev *eth_dev, int is_vf)
 			eth_dev->data->port_id, pci_dev->id.vendor_id, pci_dev->id.device_id);
 
 	if (IS_VF(sc)) {
+		rte_spinlock_init(&sc->vf2pf_lock);
+
 		if (bnx2x_dma_alloc(sc, sizeof(struct bnx2x_vf_mbx_msg),
 				    &sc->vf2pf_mbox_mapping, "vf2pf_mbox",
 				    RTE_CACHE_LINE_SIZE) != 0)
diff --git a/drivers/net/bnx2x/bnx2x_vfpf.c b/drivers/net/bnx2x/bnx2x_vfpf.c
index 46bf739..46b56b4 100644
--- a/drivers/net/bnx2x/bnx2x_vfpf.c
+++ b/drivers/net/bnx2x/bnx2x_vfpf.c
@@ -78,10 +78,13 @@ bnx2x_add_tlv(__rte_unused struct bnx2x_softc *sc, void *tlvs_list,
 
 /* Initiliaze header of the first tlv and clear mailbox*/
 static void
-bnx2x_init_first_tlv(struct bnx2x_softc *sc, struct vf_first_tlv *first_tlv,
-	uint16_t type, uint16_t length)
+bnx2x_vf_prep(struct bnx2x_softc *sc, struct vf_first_tlv *first_tlv,
+	      uint16_t type, uint16_t length)
 {
 	struct bnx2x_vf_mbx_msg *mbox = sc->vf2pf_mbox;
+
+	rte_spinlock_lock(&sc->vf2pf_lock);
+
 	PMD_DRV_LOG(DEBUG, "Preparing %d tlv for sending", type);
 
 	memset(mbox, 0, sizeof(struct bnx2x_vf_mbx_msg));
@@ -92,6 +95,17 @@ bnx2x_init_first_tlv(struct bnx2x_softc *sc, struct vf_first_tlv *first_tlv,
 	first_tlv->reply_offset = sizeof(mbox->query);
 }
 
+/* releases the mailbox */
+static void
+bnx2x_vf_finalize(struct bnx2x_softc *sc,
+		  __rte_unused struct vf_first_tlv *first_tlv)
+{
+	PMD_DRV_LOG(DEBUG, "done sending [%d] tlv over vf pf channel",
+		    first_tlv->tl.type);
+
+	rte_spinlock_unlock(&sc->vf2pf_lock);
+}
+
 #define BNX2X_VF_CMD_ADDR_LO PXP_VF_ADDR_CSDM_GLOBAL_START
 #define BNX2X_VF_CMD_ADDR_HI BNX2X_VF_CMD_ADDR_LO + 4
 #define BNX2X_VF_CMD_TRIGGER BNX2X_VF_CMD_ADDR_HI + 4
@@ -244,13 +258,16 @@ int bnx2x_vf_get_resources(struct bnx2x_softc *sc, uint8_t tx_count, uint8_t rx_
 	struct vf_acquire_tlv *acq = &sc->vf2pf_mbox->query[0].acquire;
 	int vf_id;
 	struct bnx2x_obtain_status obtain_status;
+	int rc = 0;
 
 	bnx2x_vf_close(sc);
-	bnx2x_init_first_tlv(sc, &acq->first_tlv, BNX2X_VF_TLV_ACQUIRE, sizeof(*acq));
+	bnx2x_vf_prep(sc, &acq->first_tlv, BNX2X_VF_TLV_ACQUIRE, sizeof(*acq));
 
 	vf_id = bnx2x_read_vf_id(sc);
-	if (vf_id < 0)
-		return -EAGAIN;
+	if (vf_id < 0) {
+		rc = -EAGAIN;
+		goto out;
+	}
 
 	acq->vf_id = vf_id;
 
@@ -274,8 +291,10 @@ int bnx2x_vf_get_resources(struct bnx2x_softc *sc, uint8_t tx_count, uint8_t rx_
 
 	/* requesting the resources in loop */
 	obtain_status = bnx2x_loop_obtain_resources(sc);
-	if (!obtain_status.success)
-		return obtain_status.err_code;
+	if (!obtain_status.success) {
+		rc = obtain_status.err_code;
+		goto out;
+	}
 
 	struct vf_acquire_resp_tlv sc_resp = sc->acquire_resp;
 
@@ -305,7 +324,10 @@ int bnx2x_vf_get_resources(struct bnx2x_softc *sc, uint8_t tx_count, uint8_t rx_
 		       sc_resp.resc.current_mac_addr,
 		       ETH_ALEN);
 
-	return 0;
+out:
+	bnx2x_vf_finalize(sc, &acq->first_tlv);
+
+	return rc;
 }
 
 /* Ask PF to release VF's resources */
@@ -318,8 +340,8 @@ bnx2x_vf_close(struct bnx2x_softc *sc)
 
 	if (vf_id >= 0) {
 		query = &sc->vf2pf_mbox->query[0].release;
-		bnx2x_init_first_tlv(sc, &query->first_tlv, BNX2X_VF_TLV_RELEASE,
-				sizeof(*query));
+		bnx2x_vf_prep(sc, &query->first_tlv, BNX2X_VF_TLV_RELEASE,
+			      sizeof(*query));
 
 		query->vf_id = vf_id;
 		bnx2x_add_tlv(sc, query, query->first_tlv.tl.length,
@@ -329,6 +351,8 @@ bnx2x_vf_close(struct bnx2x_softc *sc)
 		bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
 		if (reply->status != BNX2X_VF_STATUS_SUCCESS)
 			PMD_DRV_LOG(ERR, "Failed to release VF");
+
+		bnx2x_vf_finalize(sc, &query->first_tlv);
 	}
 }
 
@@ -338,11 +362,11 @@ bnx2x_vf_init(struct bnx2x_softc *sc)
 {
 	struct vf_init_tlv *query;
 	struct vf_common_reply_tlv *reply = &sc->vf2pf_mbox->resp.common_reply;
-	int i;
+	int i, rc = 0;
 
 	query = &sc->vf2pf_mbox->query[0].init;
-	bnx2x_init_first_tlv(sc, &query->first_tlv, BNX2X_VF_TLV_INIT,
-			sizeof(*query));
+	bnx2x_vf_prep(sc, &query->first_tlv, BNX2X_VF_TLV_INIT,
+		      sizeof(*query));
 
 	FOR_EACH_QUEUE(sc, i) {
 		query->sb_addr[i] = (unsigned long)(sc->fp[i].sb_dma.paddr);
@@ -359,11 +383,14 @@ bnx2x_vf_init(struct bnx2x_softc *sc)
 	bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
 	if (reply->status != BNX2X_VF_STATUS_SUCCESS) {
 		PMD_DRV_LOG(ERR, "Failed to init VF");
-		return -EINVAL;
+		rc = -EINVAL;
+		goto out;
 	}
 
 	PMD_DRV_LOG(DEBUG, "VF was initialized");
-	return 0;
+out:
+	bnx2x_vf_finalize(sc, &query->first_tlv);
+	return rc;
 }
 
 void
@@ -378,9 +405,9 @@ bnx2x_vf_unload(struct bnx2x_softc *sc)
 	if (vf_id > 0) {
 		FOR_EACH_QUEUE(sc, i) {
 			query_op = &sc->vf2pf_mbox->query[0].q_op;
-			bnx2x_init_first_tlv(sc, &query_op->first_tlv,
-					BNX2X_VF_TLV_TEARDOWN_Q,
-					sizeof(*query_op));
+			bnx2x_vf_prep(sc, &query_op->first_tlv,
+				      BNX2X_VF_TLV_TEARDOWN_Q,
+				      sizeof(*query_op));
 
 			query_op->vf_qid = i;
 
@@ -393,13 +420,15 @@ bnx2x_vf_unload(struct bnx2x_softc *sc)
 			if (reply->status != BNX2X_VF_STATUS_SUCCESS)
 				PMD_DRV_LOG(ERR,
 					    "Bad reply for vf_q %d teardown", i);
+
+			bnx2x_vf_finalize(sc, &query->first_tlv);
 		}
 
 		bnx2x_vf_set_mac(sc, false);
 
 		query = &sc->vf2pf_mbox->query[0].close;
-		bnx2x_init_first_tlv(sc, &query->first_tlv, BNX2X_VF_TLV_CLOSE,
-				sizeof(*query));
+		bnx2x_vf_prep(sc, &query->first_tlv, BNX2X_VF_TLV_CLOSE,
+			      sizeof(*query));
 
 		query->vf_id = vf_id;
 
@@ -411,6 +440,8 @@ bnx2x_vf_unload(struct bnx2x_softc *sc)
 		if (reply->status != BNX2X_VF_STATUS_SUCCESS)
 			PMD_DRV_LOG(ERR,
 				    "Bad reply from PF for close message");
+
+		bnx2x_vf_finalize(sc, &query->first_tlv);
 	}
 }
 
@@ -475,10 +506,11 @@ bnx2x_vf_setup_queue(struct bnx2x_softc *sc, struct bnx2x_fastpath *fp, int lead
 	struct vf_setup_q_tlv *query;
 	struct vf_common_reply_tlv *reply = &sc->vf2pf_mbox->resp.common_reply;
 	uint16_t flags = bnx2x_vf_q_flags(leading);
+	int rc = 0;
 
 	query = &sc->vf2pf_mbox->query[0].setup_q;
-	bnx2x_init_first_tlv(sc, &query->first_tlv, BNX2X_VF_TLV_SETUP_Q,
-			sizeof(*query));
+	bnx2x_vf_prep(sc, &query->first_tlv, BNX2X_VF_TLV_SETUP_Q,
+		      sizeof(*query));
 
 	query->vf_qid = fp->index;
 	query->param_valid = VF_RXQ_VALID | VF_TXQ_VALID;
@@ -494,10 +526,12 @@ bnx2x_vf_setup_queue(struct bnx2x_softc *sc, struct bnx2x_fastpath *fp, int lead
 	if (reply->status != BNX2X_VF_STATUS_SUCCESS) {
 		PMD_DRV_LOG(ERR, "Failed to setup VF queue[%d]",
 				 fp->index);
-		return -EINVAL;
+		rc = -EINVAL;
 	}
 
-	return 0;
+	bnx2x_vf_finalize(sc, &query->first_tlv);
+
+	return rc;
 }
 
 int
@@ -505,9 +539,10 @@ bnx2x_vf_set_mac(struct bnx2x_softc *sc, int set)
 {
 	struct vf_set_q_filters_tlv *query;
 	struct vf_common_reply_tlv *reply;
+	int rc = 0;
 
 	query = &sc->vf2pf_mbox->query[0].set_q_filters;
-	bnx2x_init_first_tlv(sc, &query->first_tlv, BNX2X_VF_TLV_SET_Q_FILTERS,
+	bnx2x_vf_prep(sc, &query->first_tlv, BNX2X_VF_TLV_SET_Q_FILTERS,
 			sizeof(*query));
 
 	query->vf_qid = sc->fp->index;
@@ -542,10 +577,12 @@ bnx2x_vf_set_mac(struct bnx2x_softc *sc, int set)
 	if (BNX2X_VF_STATUS_SUCCESS != reply->status) {
 		PMD_DRV_LOG(ERR, "Bad reply from PF for SET MAC message: %d",
 				reply->status);
-		return -EINVAL;
+		rc = -EINVAL;
 	}
 
-	return 0;
+	bnx2x_vf_finalize(sc, &query->first_tlv);
+
+	return rc;
 }
 
 int
@@ -554,10 +591,11 @@ bnx2x_vf_config_rss(struct bnx2x_softc *sc,
 {
 	struct vf_rss_tlv *query;
 	struct vf_common_reply_tlv *reply = &sc->vf2pf_mbox->resp.common_reply;
+	int rc = 0;
 
 	query = &sc->vf2pf_mbox->query[0].update_rss;
 
-	bnx2x_init_first_tlv(sc, &query->first_tlv, BNX2X_VF_TLV_UPDATE_RSS,
+	bnx2x_vf_prep(sc, &query->first_tlv, BNX2X_VF_TLV_UPDATE_RSS,
 			sizeof(*query));
 
 	/* add list termination tlv */
@@ -577,10 +615,12 @@ bnx2x_vf_config_rss(struct bnx2x_softc *sc,
 	bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
 	if (reply->status != BNX2X_VF_STATUS_SUCCESS) {
 		PMD_DRV_LOG(ERR, "Failed to configure RSS");
-		return -EINVAL;
+		rc = -EINVAL;
 	}
 
-	return 0;
+	bnx2x_vf_finalize(sc, &query->first_tlv);
+
+	return rc;
 }
 
 int
@@ -588,9 +628,10 @@ bnx2x_vf_set_rx_mode(struct bnx2x_softc *sc)
 {
 	struct vf_set_q_filters_tlv *query;
 	struct vf_common_reply_tlv *reply = &sc->vf2pf_mbox->resp.common_reply;
+	int rc = 0;
 
 	query = &sc->vf2pf_mbox->query[0].set_q_filters;
-	bnx2x_init_first_tlv(sc, &query->first_tlv, BNX2X_VF_TLV_SET_Q_FILTERS,
+	bnx2x_vf_prep(sc, &query->first_tlv, BNX2X_VF_TLV_SET_Q_FILTERS,
 			sizeof(*query));
 
 	query->vf_qid = 0;
@@ -617,7 +658,8 @@ bnx2x_vf_set_rx_mode(struct bnx2x_softc *sc)
 		break;
 	default:
 		PMD_DRV_LOG(ERR, "BAD rx mode (%d)", mode);
-		return -EINVAL;
+		rc = -EINVAL;
+		goto out;
 	}
 
 	bnx2x_add_tlv(sc, query, query->first_tlv.tl.length,
@@ -627,8 +669,11 @@ bnx2x_vf_set_rx_mode(struct bnx2x_softc *sc)
 	bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
 	if (reply->status != BNX2X_VF_STATUS_SUCCESS) {
 		PMD_DRV_LOG(ERR, "Failed to set RX mode");
-		return -EINVAL;
+		rc = -EINVAL;
 	}
 
-	return 0;
+out:
+	bnx2x_vf_finalize(sc, &query->first_tlv);
+
+	return rc;
 }
-- 
2.5.5

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [dpdk-dev] [PATCH 08/10] bnx2x: Check return codes during VF mailbox operation
  2016-07-12 13:38 [dpdk-dev] [PATCH 02/10] bnx2x: Remove unused preprocessor symbols and code Chas Williams
                   ` (4 preceding siblings ...)
  2016-07-12 13:38 ` [dpdk-dev] [PATCH 07/10] bnx2x: Serialize access to pf2vf mailbox Chas Williams
@ 2016-07-12 13:38 ` Chas Williams
  2016-07-12 13:38 ` [dpdk-dev] [PATCH 09/10] bnx2x: Don't return structs Chas Williams
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Chas Williams @ 2016-07-12 13:38 UTC (permalink / raw)
  To: dev; +Cc: harish.patil, Chas Williams

Refactor bnx2x_do_req4pf() to be easier to read and return errors when
the transaction fails -- Previously, it could succeed when the control
channel was down.

Fixes: 540a211084a7 ("bnx2x: driver core")

Signed-off-by: Chas Williams <3chas3@gmail.com>
---
 drivers/net/bnx2x/bnx2x_vfpf.c | 110 +++++++++++++++++++++++------------------
 1 file changed, 61 insertions(+), 49 deletions(-)

diff --git a/drivers/net/bnx2x/bnx2x_vfpf.c b/drivers/net/bnx2x/bnx2x_vfpf.c
index 46b56b4..70622db 100644
--- a/drivers/net/bnx2x/bnx2x_vfpf.c
+++ b/drivers/net/bnx2x/bnx2x_vfpf.c
@@ -118,39 +118,36 @@ bnx2x_do_req4pf(struct bnx2x_softc *sc, phys_addr_t phys_addr)
 	uint8_t *status = &sc->vf2pf_mbox->resp.common_reply.status;
 	uint8_t i;
 
-	if (!*status) {
-		bnx2x_check_bull(sc);
-		if (sc->old_bulletin.valid_bitmap & (1 << CHANNEL_DOWN)) {
-			PMD_DRV_LOG(ERR, "channel is down. Aborting message sending");
-			*status = BNX2X_VF_STATUS_SUCCESS;
-			return 0;
-		}
+	if (*status) {
+		PMD_DRV_LOG(ERR, "status should be zero before message"
+				 " to pf was sent");
+		return -EINVAL;
+	}
 
-		REG_WR(sc, BNX2X_VF_CMD_ADDR_LO, U64_LO(phys_addr));
-		REG_WR(sc, BNX2X_VF_CMD_ADDR_HI, U64_HI(phys_addr));
+	bnx2x_check_bull(sc);
+	if (sc->old_bulletin.valid_bitmap & (1 << CHANNEL_DOWN)) {
+		PMD_DRV_LOG(ERR, "channel is down. Aborting message sending");
+		return -EINVAL;
+	}
 
-		/* memory barrier to ensure that FW can read phys_addr */
-		wmb();
+	REG_WR(sc, BNX2X_VF_CMD_ADDR_LO, U64_LO(phys_addr));
+	REG_WR(sc, BNX2X_VF_CMD_ADDR_HI, U64_HI(phys_addr));
 
-		REG_WR8(sc, BNX2X_VF_CMD_TRIGGER, 1);
+	/* memory barrier to ensure that FW can read phys_addr */
+	wmb();
 
-		/* Do several attempts until PF completes
-		 * "." is used to show progress
-		 */
-		for (i = 0; i < BNX2X_VF_CHANNEL_TRIES; i++) {
-			DELAY_MS(BNX2X_VF_CHANNEL_DELAY);
-			if (*status)
-				break;
-		}
+	REG_WR8(sc, BNX2X_VF_CMD_TRIGGER, 1);
 
-		if (!*status) {
-			PMD_DRV_LOG(ERR, "Response from PF timed out");
-			return -EAGAIN;
-		}
-	} else {
-		PMD_DRV_LOG(ERR, "status should be zero before message"
-				"to pf was sent");
-		return -EINVAL;
+	/* Do several attempts until PF completes */
+	for (i = 0; i < BNX2X_VF_CHANNEL_TRIES; i++) {
+		DELAY_MS(BNX2X_VF_CHANNEL_DELAY);
+		if (*status)
+			break;
+	}
+
+	if (!*status) {
+		PMD_DRV_LOG(ERR, "Response from PF timed out");
+		return -EAGAIN;
 	}
 
 	PMD_DRV_LOG(DEBUG, "Response from PF was received");
@@ -337,6 +334,7 @@ bnx2x_vf_close(struct bnx2x_softc *sc)
 	struct vf_release_tlv *query;
 	struct vf_common_reply_tlv *reply = &sc->vf2pf_mbox->resp.common_reply;
 	int vf_id = bnx2x_read_vf_id(sc);
+	int rc;
 
 	if (vf_id >= 0) {
 		query = &sc->vf2pf_mbox->query[0].release;
@@ -348,8 +346,8 @@ bnx2x_vf_close(struct bnx2x_softc *sc)
 			      BNX2X_VF_TLV_LIST_END,
 			      sizeof(struct channel_list_end_tlv));
 
-		bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
-		if (reply->status != BNX2X_VF_STATUS_SUCCESS)
+		rc = bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
+		if (rc || reply->status != BNX2X_VF_STATUS_SUCCESS)
 			PMD_DRV_LOG(ERR, "Failed to release VF");
 
 		bnx2x_vf_finalize(sc, &query->first_tlv);
@@ -362,7 +360,7 @@ bnx2x_vf_init(struct bnx2x_softc *sc)
 {
 	struct vf_init_tlv *query;
 	struct vf_common_reply_tlv *reply = &sc->vf2pf_mbox->resp.common_reply;
-	int i, rc = 0;
+	int i, rc;
 
 	query = &sc->vf2pf_mbox->query[0].init;
 	bnx2x_vf_prep(sc, &query->first_tlv, BNX2X_VF_TLV_INIT,
@@ -380,7 +378,9 @@ bnx2x_vf_init(struct bnx2x_softc *sc)
 		      BNX2X_VF_TLV_LIST_END,
 		      sizeof(struct channel_list_end_tlv));
 
-	bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
+	rc = bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
+	if (rc)
+		goto out;
 	if (reply->status != BNX2X_VF_STATUS_SUCCESS) {
 		PMD_DRV_LOG(ERR, "Failed to init VF");
 		rc = -EINVAL;
@@ -399,7 +399,7 @@ bnx2x_vf_unload(struct bnx2x_softc *sc)
 	struct vf_close_tlv *query;
 	struct vf_common_reply_tlv *reply = &sc->vf2pf_mbox->resp.common_reply;
 	struct vf_q_op_tlv *query_op;
-	int i, vf_id;
+	int i, vf_id, rc;
 
 	vf_id = bnx2x_read_vf_id(sc);
 	if (vf_id > 0) {
@@ -416,8 +416,8 @@ bnx2x_vf_unload(struct bnx2x_softc *sc)
 				      BNX2X_VF_TLV_LIST_END,
 				      sizeof(struct channel_list_end_tlv));
 
-			bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
-			if (reply->status != BNX2X_VF_STATUS_SUCCESS)
+			rc = bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
+			if (rc || reply->status != BNX2X_VF_STATUS_SUCCESS)
 				PMD_DRV_LOG(ERR,
 					    "Bad reply for vf_q %d teardown", i);
 
@@ -436,8 +436,8 @@ bnx2x_vf_unload(struct bnx2x_softc *sc)
 			      BNX2X_VF_TLV_LIST_END,
 			      sizeof(struct channel_list_end_tlv));
 
-		bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
-		if (reply->status != BNX2X_VF_STATUS_SUCCESS)
+		rc = bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
+		if (rc || reply->status != BNX2X_VF_STATUS_SUCCESS)
 			PMD_DRV_LOG(ERR,
 				    "Bad reply from PF for close message");
 
@@ -506,7 +506,7 @@ bnx2x_vf_setup_queue(struct bnx2x_softc *sc, struct bnx2x_fastpath *fp, int lead
 	struct vf_setup_q_tlv *query;
 	struct vf_common_reply_tlv *reply = &sc->vf2pf_mbox->resp.common_reply;
 	uint16_t flags = bnx2x_vf_q_flags(leading);
-	int rc = 0;
+	int rc;
 
 	query = &sc->vf2pf_mbox->query[0].setup_q;
 	bnx2x_vf_prep(sc, &query->first_tlv, BNX2X_VF_TLV_SETUP_Q,
@@ -522,13 +522,15 @@ bnx2x_vf_setup_queue(struct bnx2x_softc *sc, struct bnx2x_fastpath *fp, int lead
 		      BNX2X_VF_TLV_LIST_END,
 		      sizeof(struct channel_list_end_tlv));
 
-	bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
+	rc = bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
+	if (rc)
+		goto out;
 	if (reply->status != BNX2X_VF_STATUS_SUCCESS) {
 		PMD_DRV_LOG(ERR, "Failed to setup VF queue[%d]",
 				 fp->index);
 		rc = -EINVAL;
 	}
-
+out:
 	bnx2x_vf_finalize(sc, &query->first_tlv);
 
 	return rc;
@@ -539,7 +541,7 @@ bnx2x_vf_set_mac(struct bnx2x_softc *sc, int set)
 {
 	struct vf_set_q_filters_tlv *query;
 	struct vf_common_reply_tlv *reply;
-	int rc = 0;
+	int rc;
 
 	query = &sc->vf2pf_mbox->query[0].set_q_filters;
 	bnx2x_vf_prep(sc, &query->first_tlv, BNX2X_VF_TLV_SET_Q_FILTERS,
@@ -560,7 +562,9 @@ bnx2x_vf_set_mac(struct bnx2x_softc *sc, int set)
 		      BNX2X_VF_TLV_LIST_END,
 		      sizeof(struct channel_list_end_tlv));
 
-	bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
+	rc = bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
+	if (rc)
+		goto out;
 	reply = &sc->vf2pf_mbox->resp.common_reply;
 
 	while (BNX2X_VF_STATUS_FAILURE == reply->status &&
@@ -571,7 +575,9 @@ bnx2x_vf_set_mac(struct bnx2x_softc *sc, int set)
 		rte_memcpy(query->filters[0].mac, sc->pf2vf_bulletin->mac,
 				ETH_ALEN);
 
-		bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
+		rc = bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
+		if (rc)
+			goto out;
 	}
 
 	if (BNX2X_VF_STATUS_SUCCESS != reply->status) {
@@ -579,7 +585,7 @@ bnx2x_vf_set_mac(struct bnx2x_softc *sc, int set)
 				reply->status);
 		rc = -EINVAL;
 	}
-
+out:
 	bnx2x_vf_finalize(sc, &query->first_tlv);
 
 	return rc;
@@ -591,7 +597,7 @@ bnx2x_vf_config_rss(struct bnx2x_softc *sc,
 {
 	struct vf_rss_tlv *query;
 	struct vf_common_reply_tlv *reply = &sc->vf2pf_mbox->resp.common_reply;
-	int rc = 0;
+	int rc;
 
 	query = &sc->vf2pf_mbox->query[0].update_rss;
 
@@ -612,12 +618,15 @@ bnx2x_vf_config_rss(struct bnx2x_softc *sc,
 	query->rss_result_mask = params->rss_result_mask;
 	query->rss_flags = params->rss_flags;
 
-	bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
+	rc = bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
+	if (rc)
+		goto out;
+
 	if (reply->status != BNX2X_VF_STATUS_SUCCESS) {
 		PMD_DRV_LOG(ERR, "Failed to configure RSS");
 		rc = -EINVAL;
 	}
-
+out:
 	bnx2x_vf_finalize(sc, &query->first_tlv);
 
 	return rc;
@@ -628,7 +637,7 @@ bnx2x_vf_set_rx_mode(struct bnx2x_softc *sc)
 {
 	struct vf_set_q_filters_tlv *query;
 	struct vf_common_reply_tlv *reply = &sc->vf2pf_mbox->resp.common_reply;
-	int rc = 0;
+	int rc;
 
 	query = &sc->vf2pf_mbox->query[0].set_q_filters;
 	bnx2x_vf_prep(sc, &query->first_tlv, BNX2X_VF_TLV_SET_Q_FILTERS,
@@ -666,7 +675,10 @@ bnx2x_vf_set_rx_mode(struct bnx2x_softc *sc)
 		      BNX2X_VF_TLV_LIST_END,
 		      sizeof(struct channel_list_end_tlv));
 
-	bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
+	rc = bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
+	if (rc)
+		goto out;
+
 	if (reply->status != BNX2X_VF_STATUS_SUCCESS) {
 		PMD_DRV_LOG(ERR, "Failed to set RX mode");
 		rc = -EINVAL;
-- 
2.5.5

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [dpdk-dev] [PATCH 09/10] bnx2x: Don't return structs
  2016-07-12 13:38 [dpdk-dev] [PATCH 02/10] bnx2x: Remove unused preprocessor symbols and code Chas Williams
                   ` (5 preceding siblings ...)
  2016-07-12 13:38 ` [dpdk-dev] [PATCH 08/10] bnx2x: Check return codes during VF mailbox operation Chas Williams
@ 2016-07-12 13:38 ` Chas Williams
  2016-07-12 13:38 ` [dpdk-dev] [PATCH 10/10] bnx2x: Merge debug register operations into headers Chas Williams
  2016-07-15 15:56 ` [dpdk-dev] [PATCH 02/10] bnx2x: Remove unused preprocessor symbols and code Bruce Richardson
  8 siblings, 0 replies; 11+ messages in thread
From: Chas Williams @ 2016-07-12 13:38 UTC (permalink / raw)
  To: dev; +Cc: harish.patil, Chas Williams

bnx2x_loop_obtain_resources() returns a struct.  This routine either
succeeds or fails -- We don't need a struct for that.

Fixes: 540a211084a7 ("bnx2x: driver core")

Signed-off-by: Chas Williams <3chas3@gmail.com>
---
 drivers/net/bnx2x/bnx2x_vfpf.c | 51 ++++++++++++++++--------------------------
 1 file changed, 19 insertions(+), 32 deletions(-)

diff --git a/drivers/net/bnx2x/bnx2x_vfpf.c b/drivers/net/bnx2x/bnx2x_vfpf.c
index 70622db..5fa4845 100644
--- a/drivers/net/bnx2x/bnx2x_vfpf.c
+++ b/drivers/net/bnx2x/bnx2x_vfpf.c
@@ -186,31 +186,23 @@ static inline int bnx2x_read_vf_id(struct bnx2x_softc *sc)
 #define BNX2X_VF_OBTAIN_MAC_FILTERS 1
 #define BNX2X_VF_OBTAIN_MC_FILTERS 10
 
-struct bnx2x_obtain_status {
-	int success;
-	int err_code;
-};
-
 static
-struct bnx2x_obtain_status bnx2x_loop_obtain_resources(struct bnx2x_softc *sc)
+int bnx2x_loop_obtain_resources(struct bnx2x_softc *sc)
 {
-	int tries = 0;
 	struct vf_acquire_resp_tlv *resp = &sc->vf2pf_mbox->resp.acquire_resp,
-								 *sc_resp = &sc->acquire_resp;
-	struct vf_resource_query    *res_query;
-	struct vf_resc            *resc;
-	struct bnx2x_obtain_status     status;
+				   *sc_resp = &sc->acquire_resp;
+	struct vf_resource_query   *res_query;
+	struct vf_resc		   *resc;
 	int res_obtained = false;
+	int tries = 0;
+	int rc;
 
 	do {
 		PMD_DRV_LOG(DEBUG, "trying to get resources");
 
-		if (bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr)) {
-			/* timeout */
-			status.success = 0;
-			status.err_code = -EAGAIN;
-			return status;
-		}
+		rc = bnx2x_do_req4pf(sc, sc->vf2pf_mbox_mapping.paddr);
+		if (rc)
+			return rc;
 
 		memcpy(sc_resp, resp, sizeof(sc->acquire_resp));
 
@@ -221,12 +213,12 @@ struct bnx2x_obtain_status bnx2x_loop_obtain_resources(struct bnx2x_softc *sc)
 			PMD_DRV_LOG(DEBUG, "resources obtained successfully");
 			res_obtained = true;
 		} else if (sc_resp->status == BNX2X_VF_STATUS_NO_RESOURCES &&
-			tries < BNX2X_VF_OBTAIN_MAX_TRIES) {
+			   tries < BNX2X_VF_OBTAIN_MAX_TRIES) {
 			PMD_DRV_LOG(DEBUG,
 			   "PF cannot allocate requested amount of resources");
 
 			res_query = &sc->vf2pf_mbox->query[0].acquire.res_query;
-			resc     = &sc_resp->resc;
+			resc      = &sc_resp->resc;
 
 			/* PF refused our request. Try to decrease request params */
 			res_query->num_txqs         = min(res_query->num_txqs, resc->num_txqs);
@@ -238,24 +230,21 @@ struct bnx2x_obtain_status bnx2x_loop_obtain_resources(struct bnx2x_softc *sc)
 
 			memset(&sc->vf2pf_mbox->resp, 0, sizeof(union resp_tlvs));
 		} else {
-			PMD_DRV_LOG(ERR, "Resources cannot be obtained. Status of handling: %d. Aborting",
-					sc_resp->status);
-			status.success = 0;
-			status.err_code = -EAGAIN;
-			return status;
+			PMD_DRV_LOG(ERR, "Failed to get the requested "
+					 "amount of resources: %d.",
+					 sc_resp->status);
+			return -EINVAL;
 		}
 	} while (!res_obtained);
 
-	status.success = 1;
-	return status;
+	return 0;
 }
 
 int bnx2x_vf_get_resources(struct bnx2x_softc *sc, uint8_t tx_count, uint8_t rx_count)
 {
 	struct vf_acquire_tlv *acq = &sc->vf2pf_mbox->query[0].acquire;
 	int vf_id;
-	struct bnx2x_obtain_status obtain_status;
-	int rc = 0;
+	int rc;
 
 	bnx2x_vf_close(sc);
 	bnx2x_vf_prep(sc, &acq->first_tlv, BNX2X_VF_TLV_ACQUIRE, sizeof(*acq));
@@ -287,11 +276,9 @@ int bnx2x_vf_get_resources(struct bnx2x_softc *sc, uint8_t tx_count, uint8_t rx_
 		      sizeof(struct channel_list_end_tlv));
 
 	/* requesting the resources in loop */
-	obtain_status = bnx2x_loop_obtain_resources(sc);
-	if (!obtain_status.success) {
-		rc = obtain_status.err_code;
+	rc = bnx2x_loop_obtain_resources(sc);
+	if (rc)
 		goto out;
-	}
 
 	struct vf_acquire_resp_tlv sc_resp = sc->acquire_resp;
 
-- 
2.5.5

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [dpdk-dev] [PATCH 10/10] bnx2x: Merge debug register operations into headers
  2016-07-12 13:38 [dpdk-dev] [PATCH 02/10] bnx2x: Remove unused preprocessor symbols and code Chas Williams
                   ` (6 preceding siblings ...)
  2016-07-12 13:38 ` [dpdk-dev] [PATCH 09/10] bnx2x: Don't return structs Chas Williams
@ 2016-07-12 13:38 ` Chas Williams
  2016-07-15 15:56 ` [dpdk-dev] [PATCH 02/10] bnx2x: Remove unused preprocessor symbols and code Bruce Richardson
  8 siblings, 0 replies; 11+ messages in thread
From: Chas Williams @ 2016-07-12 13:38 UTC (permalink / raw)
  To: dev; +Cc: harish.patil, Chas Williams

The register read/writes should just be static inline instead of
alternately defined as routines or macros depending on the status of
debugging.

Fix bnx2x_reg_read32() returning 0 during debug unaligned reads.

Fixes: b5bf7719221d ("bnx2x: driver support routines")

Signed-off-by: Chas Williams <3chas3@gmail.com>
---
 drivers/net/bnx2x/Makefile |  1 -
 drivers/net/bnx2x/bnx2x.h  | 99 +++++++++++++++++++++++++++++++++++++---------
 drivers/net/bnx2x/debug.c  | 96 --------------------------------------------
 3 files changed, 80 insertions(+), 116 deletions(-)
 delete mode 100644 drivers/net/bnx2x/debug.c

diff --git a/drivers/net/bnx2x/Makefile b/drivers/net/bnx2x/Makefile
index 6f1f385..0b4778b 100644
--- a/drivers/net/bnx2x/Makefile
+++ b/drivers/net/bnx2x/Makefile
@@ -24,7 +24,6 @@ SRCS-$(CONFIG_RTE_LIBRTE_BNX2X_PMD) += bnx2x_ethdev.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNX2X_PMD) += ecore_sp.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNX2X_PMD) += elink.c
 SRCS-$(CONFIG_RTE_LIBRTE_BNX2X_PMD) += bnx2x_vfpf.c
-SRCS-$(CONFIG_RTE_LIBRTE_BNX2X_DEBUG_PERIODIC) += debug.c
 
 # this lib depends upon:
 DEPDIRS-$(CONFIG_RTE_LIBRTE_BNX2X_PMD) += lib/librte_eal lib/librte_ether lib/librte_hash
diff --git a/drivers/net/bnx2x/bnx2x.h b/drivers/net/bnx2x/bnx2x.h
index d0d5b65..0ff3bf7 100644
--- a/drivers/net/bnx2x/bnx2x.h
+++ b/drivers/net/bnx2x/bnx2x.h
@@ -1412,34 +1412,95 @@ struct bnx2x_func_init_params {
 #define BAR1 2
 #define BAR2 4
 
+static inline void
+bnx2x_reg_write8(struct bnx2x_softc *sc, size_t offset, uint8_t val)
+{
+	PMD_DEBUG_PERIODIC_LOG(DEBUG, "offset=0x%08lx val=0x%02x",
+			       (unsigned long)offset, val);
+	*((volatile uint8_t*)
+	  ((uintptr_t)sc->bar[BAR0].base_addr + offset)) = val;
+}
+
+static inline void
+bnx2x_reg_write16(struct bnx2x_softc *sc, size_t offset, uint16_t val)
+{
+#ifdef RTE_LIBRTE_BNX2X_DEBUG_PERIODIC
+	if ((offset % 2) != 0)
+		PMD_DRV_LOG(NOTICE, "Unaligned 16-bit write to 0x%08lx",
+			    (unsigned long)offset);
+#endif
+	PMD_DEBUG_PERIODIC_LOG(DEBUG, "offset=0x%08lx val=0x%04x",
+			       (unsigned long)offset, val);
+	*((volatile uint16_t*)
+	  ((uintptr_t)sc->bar[BAR0].base_addr + offset)) = val;
+}
+
+static inline void
+bnx2x_reg_write32(struct bnx2x_softc *sc, size_t offset, uint32_t val)
+{
 #ifdef RTE_LIBRTE_BNX2X_DEBUG_PERIODIC
-uint8_t bnx2x_reg_read8(struct bnx2x_softc *sc, size_t offset);
-uint16_t bnx2x_reg_read16(struct bnx2x_softc *sc, size_t offset);
-uint32_t bnx2x_reg_read32(struct bnx2x_softc *sc, size_t offset);
+	if ((offset % 4) != 0)
+		PMD_DRV_LOG(NOTICE, "Unaligned 32-bit write to 0x%08lx",
+			    (unsigned long)offset);
+#endif
 
-void bnx2x_reg_write8(struct bnx2x_softc *sc, size_t offset, uint8_t val);
-void bnx2x_reg_write16(struct bnx2x_softc *sc, size_t offset, uint16_t val);
-void bnx2x_reg_write32(struct bnx2x_softc *sc, size_t offset, uint32_t val);
-#else
-#define bnx2x_reg_write8(sc, offset, val)\
-	*((volatile uint8_t*)((uintptr_t)sc->bar[BAR0].base_addr + offset)) = val
+	PMD_DEBUG_PERIODIC_LOG(DEBUG, "offset=0x%08lx val=0x%08x",
+			       (unsigned long)offset, val);
+	*((volatile uint32_t*)
+	  ((uintptr_t)sc->bar[BAR0].base_addr + offset)) = val;
+}
+
+static inline uint8_t
+bnx2x_reg_read8(struct bnx2x_softc *sc, size_t offset)
+{
+	uint8_t val;
+
+	val = (uint8_t)(*((volatile uint8_t*)
+			  ((uintptr_t) sc->bar[BAR0].base_addr + offset)));
+	PMD_DEBUG_PERIODIC_LOG(DEBUG, "offset=0x%08lx val=0x%02x",
+			       (unsigned long)offset, val);
+
+	return val;
+}
+
+static inline uint16_t
+bnx2x_reg_read16(struct bnx2x_softc *sc, size_t offset)
+{
+	uint16_t val;
 
-#define bnx2x_reg_write16(sc, offset, val)\
-	*((volatile uint16_t*)((uintptr_t)sc->bar[BAR0].base_addr + offset)) = val
+#ifdef RTE_LIBRTE_BNX2X_DEBUG_PERIODIC
+	if ((offset % 2) != 0)
+		PMD_DRV_LOG(NOTICE, "Unaligned 16-bit read from 0x%08lx",
+			    (unsigned long)offset);
+#endif
 
-#define bnx2x_reg_write32(sc, offset, val)\
-	*((volatile uint32_t*)((uintptr_t)sc->bar[BAR0].base_addr + offset)) = val
+	val = (uint16_t)(*((volatile uint16_t*)
+			   ((uintptr_t) sc->bar[BAR0].base_addr + offset)));
+	PMD_DEBUG_PERIODIC_LOG(DEBUG, "offset=0x%08lx val=0x%08x",
+			       (unsigned long)offset, val);
 
-#define bnx2x_reg_read8(sc, offset)\
-	(*((volatile uint8_t*)((uintptr_t)sc->bar[BAR0].base_addr + offset)))
+	return val;
+}
 
-#define bnx2x_reg_read16(sc, offset)\
-	(*((volatile uint16_t*)((uintptr_t)sc->bar[BAR0].base_addr + offset)))
+static inline uint32_t
+bnx2x_reg_read32(struct bnx2x_softc *sc, size_t offset)
+{
+	uint32_t val;
 
-#define bnx2x_reg_read32(sc, offset)\
-	(*((volatile uint32_t*)((uintptr_t)sc->bar[BAR0].base_addr + offset)))
+#ifdef RTE_LIBRTE_BNX2X_DEBUG_PERIODIC
+	if ((offset % 4) != 0)
+		PMD_DRV_LOG(NOTICE, "Unaligned 32-bit read from 0x%08lx",
+			    (unsigned long)offset);
 #endif
 
+	val = (uint32_t)(*((volatile uint32_t*)
+			   ((uintptr_t) sc->bar[BAR0].base_addr + offset)));
+	PMD_DEBUG_PERIODIC_LOG(DEBUG, "offset=0x%08lx val=0x%08x",
+			       (unsigned long)offset, val);
+
+	return val;
+}
+
 #define REG_ADDR(sc, offset) (((uint64_t)sc->bar[BAR0].base_addr) + (offset))
 
 #define REG_RD8(sc, offset)  bnx2x_reg_read8(sc, (offset))
diff --git a/drivers/net/bnx2x/debug.c b/drivers/net/bnx2x/debug.c
deleted file mode 100644
index cc50845..0000000
--- a/drivers/net/bnx2x/debug.c
+++ /dev/null
@@ -1,96 +0,0 @@
-/*-
- * Copyright (c) 2007-2013 QLogic Corporation. All rights reserved.
- *
- * Eric Davis        <edavis@broadcom.com>
- * David Christensen <davidch@broadcom.com>
- * Gary Zambrano     <zambrano@broadcom.com>
- *
- * Copyright (c) 2013-2015 Brocade Communications Systems, Inc.
- * Copyright (c) 2015 QLogic Corporation.
- * All rights reserved.
- * www.qlogic.com
- *
- * See LICENSE.bnx2x_pmd for copyright and licensing details.
- */
-
-#include "bnx2x.h"
-
-
-/*
- * Debug versions of the 8/16/32 bit OS register read/write functions to
- * capture/display values read/written from/to the controller.
- */
-void
-bnx2x_reg_write8(struct bnx2x_softc *sc, size_t offset, uint8_t val)
-{
-	PMD_DEBUG_PERIODIC_LOG(DEBUG, "offset=0x%08lx val=0x%02x", (unsigned long)offset, val);
-	*((volatile uint8_t*)((uintptr_t)sc->bar[BAR0].base_addr + offset)) = val;
-}
-
-void
-bnx2x_reg_write16(struct bnx2x_softc *sc, size_t offset, uint16_t val)
-{
-	if ((offset % 2) != 0) {
-		PMD_DRV_LOG(NOTICE, "Unaligned 16-bit write to 0x%08lx",
-			    (unsigned long)offset);
-	}
-
-	PMD_DEBUG_PERIODIC_LOG(DEBUG, "offset=0x%08lx val=0x%04x", (unsigned long)offset, val);
-	*((volatile uint16_t*)((uintptr_t)sc->bar[BAR0].base_addr + offset)) = val;
-}
-
-void
-bnx2x_reg_write32(struct bnx2x_softc *sc, size_t offset, uint32_t val)
-{
-	if ((offset % 4) != 0) {
-		PMD_DRV_LOG(NOTICE, "Unaligned 32-bit write to 0x%08lx",
-			    (unsigned long)offset);
-	}
-
-	PMD_DEBUG_PERIODIC_LOG(DEBUG, "offset=0x%08lx val=0x%08x", (unsigned long)offset, val);
-	*((volatile uint32_t*)((uintptr_t)sc->bar[BAR0].base_addr + offset)) = val;
-}
-
-uint8_t
-bnx2x_reg_read8(struct bnx2x_softc *sc, size_t offset)
-{
-	uint8_t val;
-
-	val = (uint8_t)(*((volatile uint8_t*)((uintptr_t)sc->bar[BAR0].base_addr + offset)));
-	PMD_DEBUG_PERIODIC_LOG(DEBUG, "offset=0x%08lx val=0x%02x", (unsigned long)offset, val);
-
-	return val;
-}
-
-uint16_t
-bnx2x_reg_read16(struct bnx2x_softc *sc, size_t offset)
-{
-	uint16_t val;
-
-	if ((offset % 2) != 0) {
-		PMD_DRV_LOG(NOTICE, "Unaligned 16-bit read from 0x%08lx",
-			    (unsigned long)offset);
-	}
-
-	val = (uint16_t)(*((volatile uint16_t*)((uintptr_t)sc->bar[BAR0].base_addr + offset)));
-	PMD_DEBUG_PERIODIC_LOG(DEBUG, "offset=0x%08lx val=0x%08x", (unsigned long)offset, val);
-
-	return val;
-}
-
-uint32_t
-bnx2x_reg_read32(struct bnx2x_softc *sc, size_t offset)
-{
-	uint32_t val;
-
-	if ((offset % 4) != 0) {
-		PMD_DRV_LOG(NOTICE, "Unaligned 32-bit read from 0x%08lx",
-			    (unsigned long)offset);
-		return 0;
-	}
-
-	val = (uint32_t)(*((volatile uint32_t*)((uintptr_t)sc->bar[BAR0].base_addr + offset)));
-	PMD_DEBUG_PERIODIC_LOG(DEBUG, "offset=0x%08lx val=0x%08x", (unsigned long)offset, val);
-
-	return val;
-}
-- 
2.5.5

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [dpdk-dev] [PATCH 02/10] bnx2x: Remove unused preprocessor symbols and code
  2016-07-12 13:38 [dpdk-dev] [PATCH 02/10] bnx2x: Remove unused preprocessor symbols and code Chas Williams
                   ` (7 preceding siblings ...)
  2016-07-12 13:38 ` [dpdk-dev] [PATCH 10/10] bnx2x: Merge debug register operations into headers Chas Williams
@ 2016-07-15 15:56 ` Bruce Richardson
  2016-07-15 18:33   ` Chas Williams
  8 siblings, 1 reply; 11+ messages in thread
From: Bruce Richardson @ 2016-07-15 15:56 UTC (permalink / raw)
  To: Chas Williams; +Cc: dev, harish.patil

On Tue, Jul 12, 2016 at 09:38:06AM -0400, Chas Williams wrote:
> ELINK_INCLUDE_EMUL and ELINK_INCLUDE_FPGA are never defined.  Remove them
> along with enumeration constants dependent on their inclusion.
> 
> Fixes: 540a211084a7 ("bnx2x: driver core")
> 
> Signed-off-by: Chas Williams <3chas3@gmail.com>

Hi Chas,

the threading on this submission is very awkward - poor patch 1 got somehow
separated from the rest of it's patch family. :-)

Besides this, given where we are in the release cycle for 16.07, these cleanups
are being deferred for possible inclusion in 16.11 (once reviewed and acked,
obviously). To get cleanup like this in in future release, please submit by
the integration deadline date.

BTW: If there are any critical bug fixes in this set, please
sent them as separate patches clearing calling them out as fixes, so they
can get the attention and review they deserve.

Thanks,
/Bruce

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [dpdk-dev] [PATCH 02/10] bnx2x: Remove unused preprocessor symbols and code
  2016-07-15 15:56 ` [dpdk-dev] [PATCH 02/10] bnx2x: Remove unused preprocessor symbols and code Bruce Richardson
@ 2016-07-15 18:33   ` Chas Williams
  0 siblings, 0 replies; 11+ messages in thread
From: Chas Williams @ 2016-07-15 18:33 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev, harish.patil

On Fri, 2016-07-15 at 16:56 +0100, Bruce Richardson wrote:
> On Tue, Jul 12, 2016 at 09:38:06AM -0400, Chas Williams wrote:
> > ELINK_INCLUDE_EMUL and ELINK_INCLUDE_FPGA are never defined.  Remove them
> > along with enumeration constants dependent on their inclusion.
> > 
> > Fixes: 540a211084a7 ("bnx2x: driver core")
> > 
> > Signed-off-by: Chas Williams <3chas3@gmail.com>
> 
> Hi Chas,
> 
> the threading on this submission is very awkward - poor patch 1 got somehow
> separated from the rest of it's patch family. :-)

Yeah, I don't know what happened there.

> Besides this, given where we are in the release cycle for 16.07, these cleanups
> are being deferred for possible inclusion in 16.11 (once reviewed and acked,
> obviously). To get cleanup like this in in future release, please submit by
> the integration deadline date.

Not a problem.  These are not urgent changes.  There are some
real issues fixed but I suspect no one runs into them.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2016-07-15 18:33 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-12 13:38 [dpdk-dev] [PATCH 02/10] bnx2x: Remove unused preprocessor symbols and code Chas Williams
2016-07-12 13:38 ` [dpdk-dev] [PATCH 03/10] bnx2x: Remove delay during device startup Chas Williams
2016-07-12 13:38 ` [dpdk-dev] [PATCH 04/10] bnx2x: Remove unused RX queue code Chas Williams
2016-07-12 13:38 ` [dpdk-dev] [PATCH 05/10] bnx2x: Restrict RX mask flags sent to the PF Chas Williams
2016-07-12 13:38 ` [dpdk-dev] [PATCH 06/10] bnx2x: Replace macro with static function Chas Williams
2016-07-12 13:38 ` [dpdk-dev] [PATCH 07/10] bnx2x: Serialize access to pf2vf mailbox Chas Williams
2016-07-12 13:38 ` [dpdk-dev] [PATCH 08/10] bnx2x: Check return codes during VF mailbox operation Chas Williams
2016-07-12 13:38 ` [dpdk-dev] [PATCH 09/10] bnx2x: Don't return structs Chas Williams
2016-07-12 13:38 ` [dpdk-dev] [PATCH 10/10] bnx2x: Merge debug register operations into headers Chas Williams
2016-07-15 15:56 ` [dpdk-dev] [PATCH 02/10] bnx2x: Remove unused preprocessor symbols and code Bruce Richardson
2016-07-15 18:33   ` Chas Williams

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).