[dpdk-dev] [PATCH 36/36] eal: Add 2 device ids for ixgbe

2015-02-12 Thread Ouyang Changchun
Accordingly, add 2 new device id into lib_eal.

Signed-off-by: Changchun Ouyang 
---
 lib/librte_eal/common/include/rte_pci_dev_ids.h | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/librte_eal/common/include/rte_pci_dev_ids.h 
b/lib/librte_eal/common/include/rte_pci_dev_ids.h
index c922de9..a2eef79 100644
--- a/lib/librte_eal/common/include/rte_pci_dev_ids.h
+++ b/lib/librte_eal/common/include/rte_pci_dev_ids.h
@@ -393,8 +393,9 @@ RTE_PCI_DEV_ID_DECL_IGB(PCI_VENDOR_ID_INTEL, 
E1000_DEV_ID_DH89XXCC_SFP)
 #define IXGBE_DEV_ID_82599_LS   0x154F
 #define IXGBE_DEV_ID_X540T  0x1528
 #define IXGBE_DEV_ID_X540T1 0x1560
-#define IXGBE_DEV_ID_X550EM_X   0x15A7
 #define IXGBE_DEV_ID_X550EM_X_SFP   0x15AC
+#define IXGBE_DEV_ID_X550EM_X_10G_T0x15AD
+#define IXGBE_DEV_ID_X550EM_X_1G_T 0x15AE
 #define IXGBE_DEV_ID_X550T  0x1563
 #define IXGBE_DEV_ID_X550EM_X_KX4   0x15AA
 #define IXGBE_DEV_ID_X550EM_X_KR0x15AB
@@ -442,8 +443,9 @@ RTE_PCI_DEV_ID_DECL_IXGBE(PCI_VENDOR_ID_INTEL, 
IXGBE_DEV_ID_82599_T3_LOM)
 RTE_PCI_DEV_ID_DECL_IXGBE(PCI_VENDOR_ID_INTEL, IXGBE_DEV_ID_82599_LS)
 RTE_PCI_DEV_ID_DECL_IXGBE(PCI_VENDOR_ID_INTEL, IXGBE_DEV_ID_X540T)
 RTE_PCI_DEV_ID_DECL_IXGBE(PCI_VENDOR_ID_INTEL, IXGBE_DEV_ID_X540T1)
-RTE_PCI_DEV_ID_DECL_IXGBE(PCI_VENDOR_ID_INTEL, IXGBE_DEV_ID_X550EM_X)
 RTE_PCI_DEV_ID_DECL_IXGBE(PCI_VENDOR_ID_INTEL, IXGBE_DEV_ID_X550EM_X_SFP)
+RTE_PCI_DEV_ID_DECL_IXGBE(PCI_VENDOR_ID_INTEL, IXGBE_DEV_ID_X550EM_X_10G_T)
+RTE_PCI_DEV_ID_DECL_IXGBE(PCI_VENDOR_ID_INTEL, IXGBE_DEV_ID_X550EM_X_1G_T)
 RTE_PCI_DEV_ID_DECL_IXGBE(PCI_VENDOR_ID_INTEL, IXGBE_DEV_ID_X550T)
 RTE_PCI_DEV_ID_DECL_IXGBE(PCI_VENDOR_ID_INTEL, IXGBE_DEV_ID_X550EM_X_KX4)
 RTE_PCI_DEV_ID_DECL_IXGBE(PCI_VENDOR_ID_INTEL, IXGBE_DEV_ID_X550EM_X_KR)
-- 
1.8.4.2



[dpdk-dev] [PATCH 34/36] ixgbe base codes: New device id

2015-02-12 Thread Ouyang Changchun
The old device id: IXGBE_DEV_ID_X550EM_X is split into 2 new device id:
IXGBE_DEV_ID_X550EM_X_10G_T and IXGBE_DEV_ID_X550EM_X_1G_T

Signed-off-by: Changchun Ouyang 
---
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.c  |  3 ++-
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h |  5 +++--
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c | 15 +--
 3 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.c 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.c
index 8037301..c704b69 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.c
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.c
@@ -167,9 +167,10 @@ s32 ixgbe_set_mac_type(struct ixgbe_hw *hw)
case IXGBE_DEV_ID_X550T:
hw->mac.type = ixgbe_mac_X550;
break;
-   case IXGBE_DEV_ID_X550EM_X:
case IXGBE_DEV_ID_X550EM_X_KX4:
case IXGBE_DEV_ID_X550EM_X_KR:
+   case IXGBE_DEV_ID_X550EM_X_10G_T:
+   case IXGBE_DEV_ID_X550EM_X_1G_T:
case IXGBE_DEV_ID_X550EM_X_SFP:
hw->mac.type = ixgbe_mac_X550EM_x;
break;
diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h
index 9fec2ad..e4432e2 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h
@@ -126,11 +126,12 @@ POSSIBILITY OF SUCH DAMAGE.
 #define IXGBE_DEV_ID_X540_VF   0x1515
 #define IXGBE_DEV_ID_X540_VF_HV0x1530
 #define IXGBE_DEV_ID_X540T10x1560
-#define IXGBE_DEV_ID_X550EM_X  0x15A7
-#define IXGBE_DEV_ID_X550EM_X_SFP  0x15AC
 #define IXGBE_DEV_ID_X550T 0x1563
 #define IXGBE_DEV_ID_X550EM_X_KX4  0x15AA
 #define IXGBE_DEV_ID_X550EM_X_KR   0x15AB
+#define IXGBE_DEV_ID_X550EM_X_SFP  0x15AC
+#define IXGBE_DEV_ID_X550EM_X_10G_T0x15AD
+#define IXGBE_DEV_ID_X550EM_X_1G_T 0x15AE
 #define IXGBE_DEV_ID_X550_VF_HV0x1564
 #define IXGBE_DEV_ID_X550_VF   0x1565
 #define IXGBE_DEV_ID_X550EM_X_VF   0x15A8
diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c
index 5faca3f..9572697 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c
@@ -109,9 +109,11 @@ STATIC s32 ixgbe_identify_phy_x550em(struct ixgbe_hw *hw)
hw->phy.type = ixgbe_phy_x550em_kx4;
break;
case IXGBE_DEV_ID_X550EM_X_KR:
-   case IXGBE_DEV_ID_X550EM_X:
hw->phy.type = ixgbe_phy_x550em_kr;
break;
+   case IXGBE_DEV_ID_X550EM_X_1G_T:
+   case IXGBE_DEV_ID_X550EM_X_10G_T:
+   return ixgbe_identify_phy_generic(hw);
default:
break;
}
@@ -401,8 +403,7 @@ s32 ixgbe_setup_eee_X550(struct ixgbe_hw *hw, bool 
enable_eee)

hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_EEE_ADVT,
IXGBE_MDIO_AUTO_NEG_DEV_TYPE, autoneg_eee_reg);
-   } else if (hw->device_id == IXGBE_DEV_ID_X550EM_X_KR ||
-  hw->device_id == IXGBE_DEV_ID_X550EM_X) {
+   } else if (hw->device_id == IXGBE_DEV_ID_X550EM_X_KR) {
status = ixgbe_read_iosf_sb_reg_x550(hw,
IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
IXGBE_SB_IOSF_TARGET_KR_PHY, _reg);
@@ -432,8 +433,7 @@ s32 ixgbe_setup_eee_X550(struct ixgbe_hw *hw, bool 
enable_eee)

hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_EEE_ADVT,
IXGBE_MDIO_AUTO_NEG_DEV_TYPE, autoneg_eee_reg);
-   } else if (hw->device_id == IXGBE_DEV_ID_X550EM_X_KR ||
-  hw->device_id == IXGBE_DEV_ID_X550EM_X) {
+   } else if (hw->device_id == IXGBE_DEV_ID_X550EM_X_KR) {
status = ixgbe_read_iosf_sb_reg_x550(hw,
IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
IXGBE_SB_IOSF_TARGET_KR_PHY, _reg);
@@ -764,7 +764,6 @@ enum ixgbe_media_type ixgbe_get_media_type_X550em(struct 
ixgbe_hw *hw)

/* Detect if there is a copper PHY attached. */
switch (hw->device_id) {
-   case IXGBE_DEV_ID_X550EM_X:
case IXGBE_DEV_ID_X550EM_X_KR:
case IXGBE_DEV_ID_X550EM_X_KX4:
media_type = ixgbe_media_type_backplane;
@@ -772,6 +771,10 @@ enum ixgbe_media_type ixgbe_get_media_type_X550em(struct 
ixgbe_hw *hw)
case IXGBE_DEV_ID_X550EM_X_SFP:
media_type = ixgbe_media_type_fiber;
break;
+   case IXGBE_DEV_ID_X550EM_X_1G_T:
+   case IXGBE_DEV_ID_X550EM_X_10G_T:
+   media_type = ixgbe_media_type_copper;
+   break;
default:
media_type = ixgbe_media_type_unknown;
break;
-- 
1.8.4.2


[dpdk-dev] [PATCH 33/36] ixgbe base codes: Read/write iosf sb stat

2015-02-12 Thread Ouyang Changchun
Update the macro to read/write iosf sb stat.

Signed-off-by: Changchun Ouyang 
---
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c
index 8301d4b..5faca3f 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c
@@ -541,7 +541,7 @@ s32 ixgbe_write_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 
reg_addr,
break;
}

-   if ((command & IXGBE_SB_IOSF_CTRL_CMPL_ERR_MASK) != 0) {
+   if ((command & IXGBE_SB_IOSF_CTRL_RESP_STAT_MASK) != 0) {
error = (command & IXGBE_SB_IOSF_CTRL_CMPL_ERR_MASK) >>
 IXGBE_SB_IOSF_CTRL_CMPL_ERR_SHIFT;
ERROR_REPORT2(IXGBE_ERROR_POLLING,
@@ -589,7 +589,7 @@ s32 ixgbe_read_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 
reg_addr,
break;
}

-   if ((command & IXGBE_SB_IOSF_CTRL_CMPL_ERR_MASK) != 0) {
+   if ((command & IXGBE_SB_IOSF_CTRL_RESP_STAT_MASK) != 0) {
error = (command & IXGBE_SB_IOSF_CTRL_CMPL_ERR_MASK) >>
 IXGBE_SB_IOSF_CTRL_CMPL_ERR_SHIFT;
ERROR_REPORT2(IXGBE_ERROR_POLLING,
-- 
1.8.4.2



[dpdk-dev] [PATCH 32/36] ixgbe base codes: Setup kx4 phy

2015-02-12 Thread Ouyang Changchun
Setup kx4 phy for x550em;

Signed-off-by: Changchun Ouyang 
---
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h | 14 +--
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c | 44 -
 2 files changed, 55 insertions(+), 3 deletions(-)

diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h
index 06b507a..9fec2ad 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h
@@ -3825,6 +3825,15 @@ struct ixgbe_hw {
 #define IXGBE_KRM_TX_COEFF_CTRL_1_CZERO_EN (1 << 3)
 #define IXGBE_KRM_TX_COEFF_CTRL_1_OVRRD_EN (1 << 31)

+#define IXGBE_KX4_LINK_CNTL_1  0x4C
+#define IXGBE_KX4_LINK_CNTL_1_TETH_AN_CAP_KX   (1 << 16)
+#define IXGBE_KX4_LINK_CNTL_1_TETH_AN_CAP_KX4  (1 << 17)
+#define IXGBE_KX4_LINK_CNTL_1_TETH_EEE_CAP_KX  (1 << 24)
+#define IXGBE_KX4_LINK_CNTL_1_TETH_EEE_CAP_KX4 (1 << 25)
+#define IXGBE_KX4_LINK_CNTL_1_TETH_AN_ENABLE   (1 << 29)
+#define IXGBE_KX4_LINK_CNTL_1_TETH_FORCE_LINK_UP   (1 << 30)
+#define IXGBE_KX4_LINK_CNTL_1_TETH_AN_RESTART  (1 << 31)
+
 #define IXGBE_SB_IOSF_INDIRECT_CTRL0x00011144
 #define IXGBE_SB_IOSF_INDIRECT_DATA0x00011148

@@ -3841,7 +3850,8 @@ struct ixgbe_hw {
 #define IXGBE_SB_IOSF_CTRL_BUSY_SHIFT  31
 #define IXGBE_SB_IOSF_CTRL_BUSY(1 << 
IXGBE_SB_IOSF_CTRL_BUSY_SHIFT)
 #define IXGBE_SB_IOSF_TARGET_KR_PHY0
-#define IXGBE_SB_IOSF_TARGET_KX4_PHY   1
-#define IXGBE_SB_IOSF_TARGET_KX4_PCS   2
+#define IXGBE_SB_IOSF_TARGET_KX4_UNIPHY1
+#define IXGBE_SB_IOSF_TARGET_KX4_PCS0  2
+#define IXGBE_SB_IOSF_TARGET_KX4_PCS1  3

 #endif /* _IXGBE_TYPE_H_ */
diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c
index 7c1d5b2..8301d4b 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c
@@ -940,6 +940,11 @@ s32 ixgbe_init_phy_ops_X550em(struct ixgbe_hw *hw)

/* Set functions pointers based on phy type */
switch (hw->phy.type) {
+   case ixgbe_phy_x550em_kx4:
+   phy->ops.setup_link = ixgbe_setup_kx4_x550em;
+   phy->ops.read_reg = ixgbe_read_phy_reg_x550em;
+   phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
+   break;
case ixgbe_phy_x550em_kr:
phy->ops.setup_link = ixgbe_setup_kr_x550em;
phy->ops.read_reg = ixgbe_read_phy_reg_x550em;
@@ -1194,7 +1199,44 @@ s32 ixgbe_setup_kr_x550em(struct ixgbe_hw *hw)
 }

 /**
- *  ixgbe_setup_ixfi_x550em - Configure the KR PHY for iXFI.
+ *  ixgbe_setup_kx4_x550em - Configure the KX4 PHY.
+ *  @hw: pointer to hardware structure
+ *
+ *  Configures the integrated KX4 PHY.
+ **/
+s32 ixgbe_setup_kx4_x550em(struct ixgbe_hw *hw)
+{
+   s32 status;
+   u32 reg_val;
+
+   status = ixgbe_read_iosf_sb_reg_x550(hw, IXGBE_KX4_LINK_CNTL_1,
+   IXGBE_SB_IOSF_TARGET_KX4_PCS0 + hw->bus.lan_id, _val);
+   if (status)
+   return status;
+
+   reg_val &= ~(IXGBE_KX4_LINK_CNTL_1_TETH_AN_CAP_KX4 |
+   IXGBE_KX4_LINK_CNTL_1_TETH_AN_CAP_KX);
+
+   reg_val |= IXGBE_KX4_LINK_CNTL_1_TETH_AN_ENABLE;
+
+   /* Advertise 10G support. */
+   if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_10GB_FULL)
+   reg_val |= IXGBE_KX4_LINK_CNTL_1_TETH_AN_CAP_KX4;
+
+   /* Advertise 1G support. */
+   if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_1GB_FULL)
+   reg_val |= IXGBE_KX4_LINK_CNTL_1_TETH_AN_CAP_KX;
+
+   /* Restart auto-negotiation. */
+   reg_val |= IXGBE_KX4_LINK_CNTL_1_TETH_AN_RESTART;
+   status = ixgbe_write_iosf_sb_reg_x550(hw, IXGBE_KX4_LINK_CNTL_1,
+   IXGBE_SB_IOSF_TARGET_KX4_PCS0 + hw->bus.lan_id, reg_val);
+
+   return status;
+}
+
+/**
+ *  ixgbe_setup_ixfi_x550em - Configure the KR PHY for iXFI mode.
  *  @hw: pointer to hardware structure
  *  @speed: the link speed to force
  *
-- 
1.8.4.2



[dpdk-dev] [PATCH 31/36] ixgbe base codes: Bit-bang mode

2015-02-12 Thread Ouyang Changchun
Support the bit-bang mode on X550;
And negate I2C output enable;

Signed-off-by: Changchun Ouyang 
---
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.c  | 66 +++--
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h |  6 +++
 2 files changed, 68 insertions(+), 4 deletions(-)

diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.c 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.c
index dc58f66..4a3463a 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.c
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.c
@@ -2103,6 +2103,7 @@ write_byte_out:
  *  @hw: pointer to hardware structure
  *
  *  Sets I2C start condition (High -> Low on SDA while SCL is High)
+ *  Set bit-bang mode on X550 hardware.
  **/
 STATIC void ixgbe_i2c_start(struct ixgbe_hw *hw)
 {
@@ -2110,6 +2111,8 @@ STATIC void ixgbe_i2c_start(struct ixgbe_hw *hw)

DEBUGFUNC("ixgbe_i2c_start");

+   i2cctl |= IXGBE_I2C_BB_EN_BY_MAC(hw);
+
/* Start condition must begin with data and clock high */
ixgbe_set_i2c_data(hw, , 1);
ixgbe_raise_i2c_clk(hw, );
@@ -2134,10 +2137,15 @@ STATIC void ixgbe_i2c_start(struct ixgbe_hw *hw)
  *  @hw: pointer to hardware structure
  *
  *  Sets I2C stop condition (Low -> High on SDA while SCL is High)
+ *  Disables bit-bang mode and negates data output enable on X550
+ *  hardware.
  **/
 STATIC void ixgbe_i2c_stop(struct ixgbe_hw *hw)
 {
u32 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
+   u32 data_oe_bit = IXGBE_I2C_DATA_OE_N_EN_BY_MAC(hw);
+   u32 clk_oe_bit = IXGBE_I2C_CLK_OE_N_EN_BY_MAC(hw);
+   u32 bb_en_bit = IXGBE_I2C_BB_EN_BY_MAC(hw);

DEBUGFUNC("ixgbe_i2c_stop");

@@ -2152,6 +2160,13 @@ STATIC void ixgbe_i2c_stop(struct ixgbe_hw *hw)

/* bus free time between stop and start (4.7us)*/
usec_delay(IXGBE_I2C_T_BUF);
+
+   if (bb_en_bit || data_oe_bit || clk_oe_bit) {
+   i2cctl &= ~bb_en_bit;
+   i2cctl |= data_oe_bit | clk_oe_bit;
+   IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), i2cctl);
+   IXGBE_WRITE_FLUSH(hw);
+   }
 }

 /**
@@ -2168,6 +2183,7 @@ STATIC s32 ixgbe_clock_in_i2c_byte(struct ixgbe_hw *hw, 
u8 *data)

DEBUGFUNC("ixgbe_clock_in_i2c_byte");

+   *data = 0;
for (i = 7; i >= 0; i--) {
ixgbe_clock_in_i2c_bit(hw, );
*data |= bit << i;
@@ -2203,6 +2219,7 @@ STATIC s32 ixgbe_clock_out_i2c_byte(struct ixgbe_hw *hw, 
u8 data)
/* Release SDA line (set high) */
i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
i2cctl |= IXGBE_I2C_DATA_OUT_BY_MAC(hw);
+   i2cctl |= IXGBE_I2C_DATA_OE_N_EN_BY_MAC(hw);
IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), i2cctl);
IXGBE_WRITE_FLUSH(hw);

@@ -2217,6 +2234,7 @@ STATIC s32 ixgbe_clock_out_i2c_byte(struct ixgbe_hw *hw, 
u8 data)
  **/
 STATIC s32 ixgbe_get_i2c_ack(struct ixgbe_hw *hw)
 {
+   u32 data_oe_bit = IXGBE_I2C_DATA_OE_N_EN_BY_MAC(hw);
s32 status = IXGBE_SUCCESS;
u32 i = 0;
u32 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
@@ -2225,9 +2243,14 @@ STATIC s32 ixgbe_get_i2c_ack(struct ixgbe_hw *hw)

DEBUGFUNC("ixgbe_get_i2c_ack");

+   if (data_oe_bit) {
+   i2cctl |= IXGBE_I2C_DATA_OUT_BY_MAC(hw);
+   i2cctl |= data_oe_bit;
+   IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), i2cctl);
+   IXGBE_WRITE_FLUSH(hw);
+   }
ixgbe_raise_i2c_clk(hw, );

-
/* Minimum high period of clock is 4us */
usec_delay(IXGBE_I2C_T_HIGH);

@@ -2265,9 +2288,16 @@ STATIC s32 ixgbe_get_i2c_ack(struct ixgbe_hw *hw)
 STATIC s32 ixgbe_clock_in_i2c_bit(struct ixgbe_hw *hw, bool *data)
 {
u32 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
+   u32 data_oe_bit = IXGBE_I2C_DATA_OE_N_EN_BY_MAC(hw);

DEBUGFUNC("ixgbe_clock_in_i2c_bit");

+   if (data_oe_bit) {
+   i2cctl |= IXGBE_I2C_DATA_OUT_BY_MAC(hw);
+   i2cctl |= data_oe_bit;
+   IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), i2cctl);
+   IXGBE_WRITE_FLUSH(hw);
+   }
ixgbe_raise_i2c_clk(hw, );

/* Minimum high period of clock is 4us */
@@ -2326,15 +2356,22 @@ STATIC s32 ixgbe_clock_out_i2c_bit(struct ixgbe_hw *hw, 
bool data)
  *  @i2cctl: Current value of I2CCTL register
  *
  *  Raises the I2C clock line '0'->'1'
+ *  Negates the I2C clock output enable on X550 hardware.
  **/
 STATIC void ixgbe_raise_i2c_clk(struct ixgbe_hw *hw, u32 *i2cctl)
 {
+   u32 clk_oe_bit = IXGBE_I2C_CLK_OE_N_EN_BY_MAC(hw);
u32 i = 0;
u32 timeout = IXGBE_I2C_CLOCK_STRETCHING_TIMEOUT;
u32 i2cctl_r = 0;

DEBUGFUNC("ixgbe_raise_i2c_clk");

+   if (clk_oe_bit) {
+   *i2cctl |= clk_oe_bit;
+   IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), *i2cctl);
+   }
+
for (i = 0; i < timeout; i++) {
*i2cctl |= IXGBE_I2C_CLK_OUT_BY_MAC(hw);

@@ -2355,13 

[dpdk-dev] [PATCH 30/36] ixgbe base codes: Auto-negotiation

2015-02-12 Thread Ouyang Changchun
Auto-negotiation for link speed of 5G.

Signed-off-by: Changchun Ouyang 
---
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.c  | 41 -
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h |  2 ++
 2 files changed, 42 insertions(+), 1 deletion(-)

diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.c 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.c
index fe5bedc..dc58f66 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.c
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.c
@@ -745,6 +745,44 @@ s32 ixgbe_setup_phy_link_generic(struct ixgbe_hw *hw)
  autoneg_reg);
}

+   if (hw->mac.type == ixgbe_mac_X550) {
+   if (speed & IXGBE_LINK_SPEED_5GB_FULL) {
+   /* Set or unset auto-negotiation 1G advertisement */
+   hw->phy.ops.read_reg(hw,
+   IXGBE_MII_AUTONEG_VENDOR_PROVISION_1_REG,
+   IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
+   _reg);
+
+   autoneg_reg &= ~IXGBE_MII_5GBASE_T_ADVERTISE;
+   if (hw->phy.autoneg_advertised &
+IXGBE_LINK_SPEED_5GB_FULL)
+   autoneg_reg |= IXGBE_MII_5GBASE_T_ADVERTISE;
+
+   hw->phy.ops.write_reg(hw,
+   IXGBE_MII_AUTONEG_VENDOR_PROVISION_1_REG,
+   IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
+   autoneg_reg);
+   }
+
+   if (speed & IXGBE_LINK_SPEED_2_5GB_FULL) {
+   /* Set or unset auto-negotiation 1G advertisement */
+   hw->phy.ops.read_reg(hw,
+   IXGBE_MII_AUTONEG_VENDOR_PROVISION_1_REG,
+   IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
+   _reg);
+
+   autoneg_reg &= ~IXGBE_MII_2_5GBASE_T_ADVERTISE;
+   if (hw->phy.autoneg_advertised &
+   IXGBE_LINK_SPEED_2_5GB_FULL)
+   autoneg_reg |= IXGBE_MII_2_5GBASE_T_ADVERTISE;
+
+   hw->phy.ops.write_reg(hw,
+   IXGBE_MII_AUTONEG_VENDOR_PROVISION_1_REG,
+   IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
+   autoneg_reg);
+   }
+   }
+
if (speed & IXGBE_LINK_SPEED_1GB_FULL) {
/* Set or unset auto-negotiation 1G advertisement */
hw->phy.ops.read_reg(hw,
@@ -840,7 +878,8 @@ s32 ixgbe_setup_phy_link_speed_generic(struct ixgbe_hw *hw,
  *  @speed: pointer to link speed
  *  @autoneg: boolean auto-negotiation value
  *
- *  Determines the link capabilities by reading the AUTOC register.
+ *  Determines the supported link capabilities by reading the PHY auto
+ *  negotiation register.
  **/
 s32 ixgbe_get_copper_link_capabilities_generic(struct ixgbe_hw *hw,
   ixgbe_link_speed *speed,
diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h
index ae760df..94f4900 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h
@@ -1433,6 +1433,8 @@ struct ixgbe_dmac_config {
 #define IXGBE_MII_10GBASE_T_ADVERTISE  0x1000 /* full duplex, bit:12*/
 #define IXGBE_MII_1GBASE_T_ADVERTISE_XNP_TX0x4000 /* full duplex, bit:14*/
 #define IXGBE_MII_1GBASE_T_ADVERTISE   0x8000 /* full duplex, bit:15*/
+#define IXGBE_MII_2_5GBASE_T_ADVERTISE 0x0400
+#define IXGBE_MII_5GBASE_T_ADVERTISE   0x0800
 #define IXGBE_MII_100BASE_T_ADVERTISE  0x0100 /* full duplex, bit:8 */
 #define IXGBE_MII_100BASE_T_ADVERTISE_HALF 0x0080 /* half duplex, bit:7 */
 #define IXGBE_MII_RESTART  0x200
-- 
1.8.4.2



[dpdk-dev] [PATCH 28/36] ixgbe base codes: Calculate checksum

2015-02-12 Thread Ouyang Changchun
Add function to calculate checksum for X550; and add buffer into argument list
to hold the eeprom image.

Signed-off-by: Changchun Ouyang 
---
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c | 74 -
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.h |  1 +
 2 files changed, 55 insertions(+), 20 deletions(-)

diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c
index bdf41da..7c1d5b2 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c
@@ -1689,19 +1689,28 @@ out:
  * Returns error status for any failure
  */
 STATIC s32 ixgbe_checksum_ptr_x550(struct ixgbe_hw *hw, u16 ptr,
-  u16 size, u16 *csum)
+  u16 size, u16 *csum, u16 *buffer,
+  u32 buffer_size)
 {
u16 buf[256];
s32 status;
u16 length, bufsz, i, start;
+   u16 *local_buffer;

bufsz = sizeof(buf) / sizeof(buf[0]);

/* Read a chunk at the pointer location */
-   status = ixgbe_read_ee_hostif_buffer_X550(hw, ptr, bufsz, buf);
-   if (status) {
-   DEBUGOUT("Failed to read EEPROM image\n");
-   return status;
+   if (!buffer) {
+   status = ixgbe_read_ee_hostif_buffer_X550(hw, ptr, bufsz, buf);
+   if (status) {
+   DEBUGOUT("Failed to read EEPROM image\n");
+   return status;
+   }
+   local_buffer = buf;
+   } else {
+   if (buffer_size < ptr)
+   return  IXGBE_ERR_PARAM;
+   local_buffer = [ptr];
}

if (size) {
@@ -1709,7 +1718,7 @@ STATIC s32 ixgbe_checksum_ptr_x550(struct ixgbe_hw *hw, 
u16 ptr,
length = size;
} else {
start = 1;
-   length = buf[0];
+   length = local_buffer[0];

/* Skip pointer section if length is invalid. */
if (length == 0x || length == 0 ||
@@ -1717,8 +1726,11 @@ STATIC s32 ixgbe_checksum_ptr_x550(struct ixgbe_hw *hw, 
u16 ptr,
return IXGBE_SUCCESS;
}

+   if (buffer && ((u32)start + (u32)length > buffer_size))
+   return IXGBE_ERR_PARAM;
+
for (i = start; length; i++, length--) {
-   if (i == bufsz) {
+   if (i == bufsz && !buffer) {
ptr += bufsz;
i = 0;
if (length < bufsz)
@@ -1732,20 +1744,23 @@ STATIC s32 ixgbe_checksum_ptr_x550(struct ixgbe_hw *hw, 
u16 ptr,
return status;
}
}
-   *csum += buf[i];
+   *csum += local_buffer[i];
}
return IXGBE_SUCCESS;
 }

 /**
- *  ixgbe_calc_eeprom_checksum_X550 - Calculates and returns the checksum
+ *  ixgbe_calc_checksum_X550 - Calculates and returns the checksum
  *  @hw: pointer to hardware structure
+ *  @buffer: pointer to buffer containing calculated checksum
+ *  @buffer_size: size of buffer
  *
  *  Returns a negative error code on error, or the 16-bit checksum
  **/
-s32 ixgbe_calc_eeprom_checksum_X550(struct ixgbe_hw *hw)
+s32 ixgbe_calc_checksum_X550(struct ixgbe_hw *hw, u16 *buffer, u32 buffer_size)
 {
u16 eeprom_ptrs[IXGBE_EEPROM_LAST_WORD + 1];
+   u16 *local_buffer;
s32 status;
u16 checksum = 0;
u16 pointer, i, size;
@@ -1754,13 +1769,20 @@ s32 ixgbe_calc_eeprom_checksum_X550(struct ixgbe_hw *hw)

hw->eeprom.ops.init_params(hw);

-   /* Read pointer area */
-   status = ixgbe_read_ee_hostif_buffer_X550(hw, 0,
- IXGBE_EEPROM_LAST_WORD + 1,
- eeprom_ptrs);
-   if (status) {
-   DEBUGOUT("Failed to read EEPROM image\n");
-   return status;
+   if (!buffer) {
+   /* Read pointer area */
+   status = ixgbe_read_ee_hostif_buffer_X550(hw, 0,
+IXGBE_EEPROM_LAST_WORD + 1,
+eeprom_ptrs);
+   if (status) {
+   DEBUGOUT("Failed to read EEPROM image\n");
+   return status;
+   }
+   local_buffer = eeprom_ptrs;
+   } else {
+   if (buffer_size < IXGBE_EEPROM_LAST_WORD)
+   return IXGBE_ERR_PARAM;
+   local_buffer = buffer;
}

/*
@@ -1769,7 +1791,7 @@ s32 ixgbe_calc_eeprom_checksum_X550(struct ixgbe_hw *hw)
 */
for (i = 0; i <= IXGBE_EEPROM_LAST_WORD; i++)
if (i != IXGBE_EEPROM_CHECKSUM)
-   checksum += eeprom_ptrs[i];
+   checksum += local_buffer[i];

/*
 * Include all data from 

[dpdk-dev] [PATCH 27/36] ixgbe base codes: Set LAN ID

2015-02-12 Thread Ouyang Changchun
LAN ID is needed for i2c access, so move it before reading I2C eeprom.

Signed-off-by: Changchun Ouyang 
---
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.c 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.c
index 6d1b0e6..fe5bedc 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.c
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.c
@@ -1217,6 +1217,9 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw)
goto out;
}

+   /* LAN ID is needed for I2C access */
+   hw->mac.ops.set_lan_id(hw);
+
status = hw->phy.ops.read_i2c_eeprom(hw,
 IXGBE_SFF_IDENTIFIER,
 );
@@ -1224,9 +1227,6 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw)
if (status != IXGBE_SUCCESS)
goto err_read_i2c_eeprom;

-   /* LAN ID is needed for sfp_type determination */
-   hw->mac.ops.set_lan_id(hw);
-
if (identifier != IXGBE_SFF_IDENTIFIER_SFP) {
hw->phy.type = ixgbe_phy_sfp_unsupported;
status = IXGBE_ERR_SFP_NOT_SUPPORTED;
-- 
1.8.4.2



[dpdk-dev] [PATCH 26/36] ixgbe base codes: SFP probe

2015-02-12 Thread Ouyang Changchun
Check if SFP is detected or not.

Signed-off-by: Changchun Ouyang 
---
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.c | 18 ++
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.h |  4 
 2 files changed, 22 insertions(+)

diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.c 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.c
index 3a4ffc1..6d1b0e6 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.c
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.c
@@ -1890,6 +1890,21 @@ s32 ixgbe_write_i2c_eeprom_generic(struct ixgbe_hw *hw, 
u8 byte_offset,
 }

 /**
+ * ixgbe_is_sfp_probe - Returns true if SFP is being detected
+ * @hw: pointer to hardware structure
+ * @offset: eeprom offset to be read
+ * @addr: I2C address to be read
+ */
+STATIC bool ixgbe_is_sfp_probe(struct ixgbe_hw *hw, u8 offset, u8 addr)
+{
+   if (addr == IXGBE_I2C_EEPROM_DEV_ADDR &&
+   offset == IXGBE_SFF_IDENTIFIER &&
+   hw->phy.sfp_type == ixgbe_sfp_type_not_present)
+   return true;
+   return false;
+}
+
+/**
  *  ixgbe_read_i2c_byte_generic - Reads 8 bit word over I2C
  *  @hw: pointer to hardware structure
  *  @byte_offset: byte offset to read
@@ -1910,6 +1925,9 @@ s32 ixgbe_read_i2c_byte_generic(struct ixgbe_hw *hw, u8 
byte_offset,

DEBUGFUNC("ixgbe_read_i2c_byte_generic");

+   if (ixgbe_is_sfp_probe(hw, byte_offset, dev_addr))
+   max_retry = IXGBE_SFP_DETECT_RETRIES;
+
do {
if (hw->mac.ops.acquire_swfw_sync(hw, swfw_mask))
return IXGBE_ERR_SWFW_SYNC;
diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.h 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.h
index 805b9f9..21d88f7 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.h
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.h
@@ -114,6 +114,10 @@ POSSIBILITY OF SUCH DAMAGE.
 #define IXGBE_I2C_T_SU_STO 4
 #define IXGBE_I2C_T_BUF5

+#ifndef IXGBE_SFP_DETECT_RETRIES
+#define IXGBE_SFP_DETECT_RETRIES   10
+
+#endif /* IXGBE_SFP_DETECT_RETRIES */
 #define IXGBE_TN_LASI_STATUS_REG   0x9005
 #define IXGBE_TN_LASI_STATUS_TEMP_ALARM0x0008

-- 
1.8.4.2



[dpdk-dev] [PATCH 25/36] ixgbe base codes: Refine branch statement

2015-02-12 Thread Ouyang Changchun
Use switch-case statement to replace if-else statement.

Signed-off-by: Changchun Ouyang 
---
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.c | 17 +
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.c 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.c
index 1a536d8..d801de3 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.c
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.c
@@ -4079,26 +4079,27 @@ s32 ixgbe_check_mac_link_generic(struct ixgbe_hw *hw, 
ixgbe_link_speed *speed,
*link_up = false;
}

-   if ((links_reg & IXGBE_LINKS_SPEED_82599) ==
-   IXGBE_LINKS_SPEED_10G_82599) {
+   switch (links_reg & IXGBE_LINKS_SPEED_82599) {
+   case IXGBE_LINKS_SPEED_10G_82599:
*speed = IXGBE_LINK_SPEED_10GB_FULL;
if (hw->mac.type >= ixgbe_mac_X550) {
if (links_reg & IXGBE_LINKS_SPEED_NON_STD)
*speed = IXGBE_LINK_SPEED_2_5GB_FULL;
}
-   }
-   else if ((links_reg & IXGBE_LINKS_SPEED_82599) ==
-IXGBE_LINKS_SPEED_1G_82599)
+   break;
+   case IXGBE_LINKS_SPEED_1G_82599:
*speed = IXGBE_LINK_SPEED_1GB_FULL;
-   else if ((links_reg & IXGBE_LINKS_SPEED_82599) ==
-IXGBE_LINKS_SPEED_100_82599)
+   break;
+   case IXGBE_LINKS_SPEED_100_82599:
*speed = IXGBE_LINK_SPEED_100_FULL;
-   else
if (hw->mac.type >= ixgbe_mac_X550) {
if (links_reg & IXGBE_LINKS_SPEED_NON_STD)
*speed = IXGBE_LINK_SPEED_5GB_FULL;
}
+   break;
+   default:
*speed = IXGBE_LINK_SPEED_UNKNOWN;
+   }

return IXGBE_SUCCESS;
 }
-- 
1.8.4.2



[dpdk-dev] [PATCH 24/36] ixgbe base codes: Support 5G link speed

2015-02-12 Thread Ouyang Changchun
Support 5G link speed for X550.

Signed-off-by: Changchun Ouyang 
---
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.c |  4 
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.c| 15 +++
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h   |  3 ++-
 3 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.c 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.c
index bee36f4..1a536d8 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.c
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.c
@@ -4094,6 +4094,10 @@ s32 ixgbe_check_mac_link_generic(struct ixgbe_hw *hw, 
ixgbe_link_speed *speed,
 IXGBE_LINKS_SPEED_100_82599)
*speed = IXGBE_LINK_SPEED_100_FULL;
else
+   if (hw->mac.type >= ixgbe_mac_X550) {
+   if (links_reg & IXGBE_LINKS_SPEED_NON_STD)
+   *speed = IXGBE_LINK_SPEED_5GB_FULL;
+   }
*speed = IXGBE_LINK_SPEED_UNKNOWN;

return IXGBE_SUCCESS;
diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.c 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.c
index 8a96e43..3a4ffc1 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.c
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.c
@@ -816,6 +816,12 @@ s32 ixgbe_setup_phy_link_speed_generic(struct ixgbe_hw *hw,
if (speed & IXGBE_LINK_SPEED_10GB_FULL)
hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_10GB_FULL;

+   if (speed & IXGBE_LINK_SPEED_5GB_FULL)
+   hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_5GB_FULL;
+
+   if (speed & IXGBE_LINK_SPEED_2_5GB_FULL)
+   hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_2_5GB_FULL;
+
if (speed & IXGBE_LINK_SPEED_1GB_FULL)
hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_1GB_FULL;

@@ -861,6 +867,15 @@ s32 ixgbe_get_copper_link_capabilities_generic(struct 
ixgbe_hw *hw,
*speed |= IXGBE_LINK_SPEED_100_FULL;
}

+   /* Internal PHY does not support 100 Mbps */
+   if (hw->mac.type == ixgbe_mac_X550EM_x)
+   *speed &= ~IXGBE_LINK_SPEED_100_FULL;
+
+   if (hw->mac.type == ixgbe_mac_X550) {
+   *speed |= IXGBE_LINK_SPEED_2_5GB_FULL;
+   *speed |= IXGBE_LINK_SPEED_5GB_FULL;
+   }
+
return status;
 }

diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h
index 8946006..ae760df 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h
@@ -3032,7 +3032,8 @@ typedef u32 ixgbe_link_speed;
 #define IXGBE_LINK_SPEED_UNKNOWN   0
 #define IXGBE_LINK_SPEED_100_FULL  0x0008
 #define IXGBE_LINK_SPEED_1GB_FULL  0x0020
-#define IXGBE_LINK_SPEED_2_5GB_FULL0x0040
+#define IXGBE_LINK_SPEED_2_5GB_FULL0x0400
+#define IXGBE_LINK_SPEED_5GB_FULL  0x0800
 #define IXGBE_LINK_SPEED_10GB_FULL 0x0080
 #define IXGBE_LINK_SPEED_82598_AUTONEG (IXGBE_LINK_SPEED_1GB_FULL | \
 IXGBE_LINK_SPEED_10GB_FULL)
-- 
1.8.4.2



[dpdk-dev] [PATCH 23/36] ixgbe base codes: API for write i2c combined

2015-02-12 Thread Ouyang Changchun
New API to perform I2C write combined operation.

Signed-off-by: Changchun Ouyang 
---
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.c  | 16 
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.h  |  1 +
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c | 11 +--
 3 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.c 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.c
index ae13adb..8037301 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.c
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.c
@@ -1326,6 +1326,7 @@ s32 ixgbe_read_i2c_combined(struct ixgbe_hw *hw, u8 addr, 
u16 reg, u16 *val)
  *  ixgbe_write_i2c_byte - Writes 8 bit word over I2C
  *  @hw: pointer to hardware structure
  *  @byte_offset: byte offset to write
+ *  @dev_addr: I2C bus address to write to
  *  @data: value to write
  *
  *  Performs byte write operation to SFP module's EEPROM over I2C interface
@@ -1339,6 +1340,21 @@ s32 ixgbe_write_i2c_byte(struct ixgbe_hw *hw, u8 
byte_offset, u8 dev_addr,
 }

 /**
+ * ixgbe_write_i2c_combined - Perform I2C write combined operation
+ * @hw: pointer to the hardware structure
+ * @addr: I2C bus address to write to
+ * @reg: I2C device register to write to
+ * @val: value to write
+ *
+ * Returns an error code on error.
+ */
+s32 ixgbe_write_i2c_combined(struct ixgbe_hw *hw, u8 addr, u16 reg, u16 val)
+{
+   return ixgbe_call_func(hw, hw->phy.ops.write_i2c_combined, (hw, addr,
+  reg, val), IXGBE_NOT_IMPLEMENTED);
+}
+
+/**
  *  ixgbe_write_i2c_eeprom - Writes 8 bit EEPROM word over I2C interface
  *  @hw: pointer to hardware structure
  *  @byte_offset: EEPROM byte offset to write
diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.h 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.h
index 77ebc64..8386e29 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.h
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.h
@@ -174,6 +174,7 @@ s32 ixgbe_read_i2c_byte(struct ixgbe_hw *hw, u8 
byte_offset, u8 dev_addr,
 s32 ixgbe_read_i2c_combined(struct ixgbe_hw *hw, u8 addr, u16 reg, u16 *val);
 s32 ixgbe_write_i2c_byte(struct ixgbe_hw *hw, u8 byte_offset, u8 dev_addr,
 u8 data);
+s32 ixgbe_write_i2c_combined(struct ixgbe_hw *hw, u8 addr, u16 reg, u16 val);
 s32 ixgbe_write_i2c_eeprom(struct ixgbe_hw *hw, u8 byte_offset, u8 
eeprom_data);
 s32 ixgbe_get_san_mac_addr(struct ixgbe_hw *hw, u8 *san_mac_addr);
 s32 ixgbe_set_san_mac_addr(struct ixgbe_hw *hw, u8 *san_mac_addr);
diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c
index d8a0c19..bdf41da 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c
@@ -787,6 +787,7 @@ s32 ixgbe_setup_sfp_modules_X550em(struct ixgbe_hw *hw)
 {
bool setup_linear;
u16 reg_slice, edc_mode;
+   s32 ret_val;

DEBUGFUNC("ixgbe_setup_sfp_modules_X550em");

@@ -827,8 +828,14 @@ s32 ixgbe_setup_sfp_modules_X550em(struct ixgbe_hw *hw)
edc_mode = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;

/* Configure CS4227 for connection type. */
-   return hw->phy.ops.write_i2c_combined(hw, IXGBE_CS4227,
- reg_slice, edc_mode);
+   ret_val = ixgbe_write_i2c_combined(hw, IXGBE_CS4227, reg_slice,
+  edc_mode);
+
+   if (ret_val != IXGBE_SUCCESS)
+   ret_val = ixgbe_write_i2c_combined(hw, 0x80, reg_slice,
+  edc_mode);
+
+   return ret_val;
 }

 /**
-- 
1.8.4.2



[dpdk-dev] [PATCH 22/36] ixgbe base codes: API for read i2c combined

2015-02-12 Thread Ouyang Changchun
New API to perform I2C read combined operation.

Signed-off-by: Changchun Ouyang 
---
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.c | 16 
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.h |  1 +
 2 files changed, 17 insertions(+)

diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.c 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.c
index c49b1cd..ae13adb 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.c
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.c
@@ -1295,6 +1295,7 @@ s32 ixgbe_init_uta_tables(struct ixgbe_hw *hw)
  *  ixgbe_read_i2c_byte - Reads 8 bit word over I2C at specified device address
  *  @hw: pointer to hardware structure
  *  @byte_offset: byte offset to read
+ *  @dev_addr: I2C bus address to read from
  *  @data: value read
  *
  *  Performs byte read operation to SFP module's EEPROM over I2C interface.
@@ -1307,6 +1308,21 @@ s32 ixgbe_read_i2c_byte(struct ixgbe_hw *hw, u8 
byte_offset, u8 dev_addr,
 }

 /**
+ * ixgbe_read_i2c_combined - Perform I2C read combined operation
+ * @hw: pointer to the hardware structure
+ * @addr: I2C bus address to read from
+ * @reg: I2C device register to read from
+ * @val: pointer to location to receive read value
+ *
+ * Returns an error code on error.
+ */
+s32 ixgbe_read_i2c_combined(struct ixgbe_hw *hw, u8 addr, u16 reg, u16 *val)
+{
+   return ixgbe_call_func(hw, hw->phy.ops.read_i2c_combined, (hw, addr,
+  reg, val), IXGBE_NOT_IMPLEMENTED);
+}
+
+/**
  *  ixgbe_write_i2c_byte - Writes 8 bit word over I2C
  *  @hw: pointer to hardware structure
  *  @byte_offset: byte offset to write
diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.h 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.h
index db1dd96..77ebc64 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.h
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.h
@@ -171,6 +171,7 @@ u32 ixgbe_atr_compute_sig_hash_82599(union 
ixgbe_atr_hash_dword input,
 bool ixgbe_verify_lesm_fw_enabled_82599(struct ixgbe_hw *hw);
 s32 ixgbe_read_i2c_byte(struct ixgbe_hw *hw, u8 byte_offset, u8 dev_addr,
u8 *data);
+s32 ixgbe_read_i2c_combined(struct ixgbe_hw *hw, u8 addr, u16 reg, u16 *val);
 s32 ixgbe_write_i2c_byte(struct ixgbe_hw *hw, u8 byte_offset, u8 dev_addr,
 u8 data);
 s32 ixgbe_write_i2c_eeprom(struct ixgbe_hw *hw, u8 byte_offset, u8 
eeprom_data);
-- 
1.8.4.2



[dpdk-dev] [PATCH 21/36] ixgbe base codes: API for set phy power

2015-02-12 Thread Ouyang Changchun
New API to control the phy power state.

Signed-off-by: Changchun Ouyang 
---
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.c | 11 +++
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.h |  1 +
 2 files changed, 12 insertions(+)

diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.c 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.c
index ff2e6dc..c49b1cd 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.c
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.c
@@ -580,6 +580,17 @@ s32 ixgbe_setup_phy_link_speed(struct ixgbe_hw *hw, 
ixgbe_link_speed speed,
 }

 /**
+ * ixgbe_set_phy_power - Control the phy power state
+ * @hw: pointer to hardware structure
+ * @on: true for on, false for off
+ */
+s32 ixgbe_set_phy_power(struct ixgbe_hw *hw, bool on)
+{
+   return ixgbe_call_func(hw, hw->phy.ops.set_phy_power, (hw, on),
+  IXGBE_NOT_IMPLEMENTED);
+}
+
+/**
  *  ixgbe_check_link - Get link and speed status
  *  @hw: pointer to hardware structure
  *
diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.h 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.h
index fc981df..db1dd96 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.h
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.h
@@ -77,6 +77,7 @@ s32 ixgbe_check_phy_link(struct ixgbe_hw *hw,
 s32 ixgbe_setup_phy_link_speed(struct ixgbe_hw *hw,
   ixgbe_link_speed speed,
   bool autoneg_wait_to_complete);
+s32 ixgbe_set_phy_power(struct ixgbe_hw *, bool on);
 void ixgbe_disable_tx_laser(struct ixgbe_hw *hw);
 void ixgbe_enable_tx_laser(struct ixgbe_hw *hw);
 void ixgbe_flap_tx_laser(struct ixgbe_hw *hw);
-- 
1.8.4.2



[dpdk-dev] [PATCH 20/36] ixgbe base codes: API for setup internal phy

2015-02-12 Thread Ouyang Changchun
New API for setup internal phy.

Signed-off-by: Changchun Ouyang 
---
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.c | 14 ++
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.h |  1 +
 2 files changed, 15 insertions(+)

diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.c 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.c
index 9d8ea27..ff2e6dc 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.c
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.c
@@ -537,6 +537,20 @@ s32 ixgbe_setup_phy_link(struct ixgbe_hw *hw)
 }

 /**
+ * ixgbe_setup_internal_phy - Configure integrated PHY
+ * @hw: pointer to hardware structure
+ *
+ * Reconfigure the integrated PHY in order to enable talk to the external PHY.
+ * Returns success if not implemented, since nothing needs to be done in this
+ * case.
+ */
+s32 ixgbe_setup_internal_phy(struct ixgbe_hw *hw)
+{
+   return ixgbe_call_func(hw, hw->phy.ops.setup_internal_link, (hw),
+  IXGBE_SUCCESS);
+}
+
+/**
  *  ixgbe_check_phy_link - Determine link and speed status
  *  @hw: pointer to hardware structure
  *
diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.h 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.h
index cb6208d..fc981df 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.h
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.h
@@ -70,6 +70,7 @@ s32 ixgbe_write_phy_reg(struct ixgbe_hw *hw, u32 reg_addr, 
u32 device_type,
u16 phy_data);

 s32 ixgbe_setup_phy_link(struct ixgbe_hw *hw);
+s32 ixgbe_setup_internal_phy(struct ixgbe_hw *hw);
 s32 ixgbe_check_phy_link(struct ixgbe_hw *hw,
 ixgbe_link_speed *speed,
 bool *link_up);
-- 
1.8.4.2



[dpdk-dev] [PATCH 19/36] ixgbe base codes: Fix mac type issue

2015-02-12 Thread Ouyang Changchun
It needs '>=' rather than '=='.

Signed-off-by: Changchun Ouyang 
---
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.c| 2 +-
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_dcb_82599.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.c 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.c
index 5667216..bee36f4 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.c
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.c
@@ -4082,7 +4082,7 @@ s32 ixgbe_check_mac_link_generic(struct ixgbe_hw *hw, 
ixgbe_link_speed *speed,
if ((links_reg & IXGBE_LINKS_SPEED_82599) ==
IXGBE_LINKS_SPEED_10G_82599) {
*speed = IXGBE_LINK_SPEED_10GB_FULL;
-   if (hw->mac.type > ixgbe_mac_X550) {
+   if (hw->mac.type >= ixgbe_mac_X550) {
if (links_reg & IXGBE_LINKS_SPEED_NON_STD)
*speed = IXGBE_LINK_SPEED_2_5GB_FULL;
}
diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_dcb_82599.c 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_dcb_82599.c
index 469db66..9778164 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_dcb_82599.c
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_dcb_82599.c
@@ -298,7 +298,7 @@ s32 ixgbe_dcb_config_pfc_82599(struct ixgbe_hw *hw, u8 
pfc_en, u8 *map)
 */
reg &= ~(IXGBE_MFLCN_RPFCE_MASK | IXGBE_MFLCN_RFCE);

-   if (hw->mac.type == ixgbe_mac_X540)
+   if (hw->mac.type >= ixgbe_mac_X540)
reg |= pfc_en << IXGBE_MFLCN_RPFCE_SHIFT;

if (pfc_en)
-- 
1.8.4.2



[dpdk-dev] [PATCH 18/36] ixgbe base codes: Restructure host interface command

2015-02-12 Thread Ouyang Changchun
Request and response command have different struct.

Signed-off-by: Changchun Ouyang 
---
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h | 22 -
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c | 34 -
 2 files changed, 34 insertions(+), 22 deletions(-)

diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h
index 6043eac..8946006 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h
@@ -2821,13 +2821,25 @@ struct ixgbe_hic_hdr {
u8 checksum;
 };

-struct ixgbe_hic_hdr2 {
+struct ixgbe_hic_hdr2_req {
u8 cmd;
-   u8 buf_len1;
-   u8 buf_len2;
+   u8 buf_lenh;
+   u8 buf_lenl;
u8 checksum;
 };

+struct ixgbe_hic_hdr2_rsp {
+   u8 cmd;
+   u8 buf_lenl;
+   u8 buf_lenh_status; /* 7-5: high bits of buf_len, 4-0: status */
+   u8 checksum;
+};
+
+union ixgbe_hic_hdr2 {
+   struct ixgbe_hic_hdr2_req req;
+   struct ixgbe_hic_hdr2_rsp rsp;
+};
+
 struct ixgbe_hic_drv_info {
struct ixgbe_hic_hdr hdr;
u8 port_num;
@@ -2841,7 +2853,7 @@ struct ixgbe_hic_drv_info {

 /* These need to be dword aligned */
 struct ixgbe_hic_read_shadow_ram {
-   struct ixgbe_hic_hdr2 hdr;
+   union ixgbe_hic_hdr2 hdr;
u32 address;
u16 length;
u16 pad2;
@@ -2850,7 +2862,7 @@ struct ixgbe_hic_read_shadow_ram {
 };

 struct ixgbe_hic_write_shadow_ram {
-   struct ixgbe_hic_hdr2 hdr;
+   union ixgbe_hic_hdr2 hdr;
u32 address;
u16 length;
u16 pad2;
diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c
index e3d8fc1..d8a0c19 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c
@@ -1450,10 +1450,10 @@ s32 ixgbe_read_ee_hostif_data_X550(struct ixgbe_hw *hw, 
u16 offset,
struct ixgbe_hic_read_shadow_ram buffer;

DEBUGFUNC("ixgbe_read_ee_hostif_data_X550");
-   buffer.hdr.cmd = FW_READ_SHADOW_RAM_CMD;
-   buffer.hdr.buf_len1 = 0;
-   buffer.hdr.buf_len2 = FW_READ_SHADOW_RAM_LEN;
-   buffer.hdr.checksum = FW_DEFAULT_CHECKSUM;
+   buffer.hdr.req.cmd = FW_READ_SHADOW_RAM_CMD;
+   buffer.hdr.req.buf_lenh = 0;
+   buffer.hdr.req.buf_lenl = FW_READ_SHADOW_RAM_LEN;
+   buffer.hdr.req.checksum = FW_DEFAULT_CHECKSUM;

/* convert offset from words to bytes */
buffer.address = IXGBE_CPU_TO_BE32(offset * 2);
@@ -1531,10 +1531,10 @@ s32 ixgbe_read_ee_hostif_buffer_X550(struct ixgbe_hw 
*hw,
else
words_to_read = words;

-   buffer.hdr.cmd = FW_READ_SHADOW_RAM_CMD;
-   buffer.hdr.buf_len1 = 0;
-   buffer.hdr.buf_len2 = FW_READ_SHADOW_RAM_LEN;
-   buffer.hdr.checksum = FW_DEFAULT_CHECKSUM;
+   buffer.hdr.req.cmd = FW_READ_SHADOW_RAM_CMD;
+   buffer.hdr.req.buf_lenh = 0;
+   buffer.hdr.req.buf_lenl = FW_READ_SHADOW_RAM_LEN;
+   buffer.hdr.req.checksum = FW_DEFAULT_CHECKSUM;

/* convert offset from words to bytes */
buffer.address = IXGBE_CPU_TO_BE32((offset + current_word) * 2);
@@ -1588,10 +1588,10 @@ s32 ixgbe_write_ee_hostif_data_X550(struct ixgbe_hw 
*hw, u16 offset,

DEBUGFUNC("ixgbe_write_ee_hostif_data_X550");

-   buffer.hdr.cmd = FW_WRITE_SHADOW_RAM_CMD;
-   buffer.hdr.buf_len1 = 0;
-   buffer.hdr.buf_len2 = FW_WRITE_SHADOW_RAM_LEN;
-   buffer.hdr.checksum = FW_DEFAULT_CHECKSUM;
+   buffer.hdr.req.cmd = FW_WRITE_SHADOW_RAM_CMD;
+   buffer.hdr.req.buf_lenh = 0;
+   buffer.hdr.req.buf_lenl = FW_WRITE_SHADOW_RAM_LEN;
+   buffer.hdr.req.checksum = FW_DEFAULT_CHECKSUM;

 /* one word */
buffer.length = IXGBE_CPU_TO_BE16(sizeof(u16));
@@ -1905,14 +1905,14 @@ s32 ixgbe_update_eeprom_checksum_X550(struct ixgbe_hw 
*hw)
 s32 ixgbe_update_flash_X550(struct ixgbe_hw *hw)
 {
s32 status = IXGBE_SUCCESS;
-   struct ixgbe_hic_hdr2 buffer;
+   union ixgbe_hic_hdr2 buffer;

DEBUGFUNC("ixgbe_update_flash_X550");

-   buffer.cmd = FW_SHADOW_RAM_DUMP_CMD;
-   buffer.buf_len1 = 0;
-   buffer.buf_len2 = FW_SHADOW_RAM_DUMP_LEN;
-   buffer.checksum = FW_DEFAULT_CHECKSUM;
+   buffer.req.cmd = FW_SHADOW_RAM_DUMP_CMD;
+   buffer.req.buf_lenh = 0;
+   buffer.req.buf_lenl = FW_SHADOW_RAM_DUMP_LEN;
+   buffer.req.checksum = FW_DEFAULT_CHECKSUM;

status = ixgbe_host_interface_command(hw, (u32 *),
  sizeof(buffer),
-- 
1.8.4.2



[dpdk-dev] [PATCH 17/36] ixgbe base codes: Get bus info

2015-02-12 Thread Ouyang Changchun
New function to get bus information for x550em;

Signed-off-by: Changchun Ouyang 
---
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h |  1 +
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c | 23 +--
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.h |  1 +
 3 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h
index 459e0e3..6043eac 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h
@@ -3324,6 +3324,7 @@ enum ixgbe_bus_type {
ixgbe_bus_type_pci,
ixgbe_bus_type_pcix,
ixgbe_bus_type_pci_express,
+   ixgbe_bus_type_internal,
ixgbe_bus_type_reserved
 };

diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c
index c07e4e9..e3d8fc1 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c
@@ -171,8 +171,9 @@ s32 ixgbe_init_ops_X550EM(struct ixgbe_hw *hw)
mac->ops.disable_sec_rx_path = NULL;
mac->ops.enable_sec_rx_path = NULL;

-   /* PCIe bus info not supported in X550EM */
-   mac->ops.get_bus_info = NULL;
+   /* X550EM bus type is internal*/
+   hw->bus.type = ixgbe_bus_type_internal;
+   mac->ops.get_bus_info = ixgbe_get_bus_info_X550em;

mac->ops.read_iosf_sb_reg = ixgbe_read_iosf_sb_reg_x550;
mac->ops.write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550;
@@ -1964,6 +1965,24 @@ u32 ixgbe_get_supported_physical_layer_X550em(struct 
ixgbe_hw *hw)
 }

 /**
+ * ixgbe_get_bus_info_x550em - Set PCI bus info
+ * @hw: pointer to hardware structure
+ *
+ * Sets bus link width and speed to unknown because X550em is
+ * not a PCI device.
+ **/
+s32 ixgbe_get_bus_info_X550em(struct ixgbe_hw *hw)
+{
+
+   DEBUGFUNC("ixgbe_get_bus_info_x550em");
+
+   hw->bus.width = ixgbe_bus_width_unknown;
+   hw->bus.speed = ixgbe_bus_speed_unknown;
+
+   return IXGBE_SUCCESS;
+}
+
+/**
  * ixgbe_disable_rx_x550 - Disable RX unit
  *
  * Enables the Rx DMA unit for x550
diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.h 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.h
index 8804777..8c78cb1 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.h
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.h
@@ -40,6 +40,7 @@ s32 ixgbe_dmac_config_X550(struct ixgbe_hw *hw);
 s32 ixgbe_dmac_config_tcs_X550(struct ixgbe_hw *hw);
 s32 ixgbe_dmac_update_tcs_X550(struct ixgbe_hw *hw);

+s32 ixgbe_get_bus_info_X550em(struct ixgbe_hw *hw);
 s32 ixgbe_init_eeprom_params_X550(struct ixgbe_hw *hw);
 s32 ixgbe_update_eeprom_checksum_X550(struct ixgbe_hw *hw);
 s32 ixgbe_calc_eeprom_checksum_X550(struct ixgbe_hw *hw);
-- 
1.8.4.2



[dpdk-dev] [PATCH 16/36] ixgbe base codes: New phy ID

2015-02-12 Thread Ouyang Changchun
Add new phy ID: X557_PHY_ID, and implement its internal setup function and 
external init function.

Signed-off-by: Changchun Ouyang 
---
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.c  |   3 +
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h |  10 ++
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c | 204 +++-
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.h |   4 +-
 4 files changed, 215 insertions(+), 6 deletions(-)

diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.c 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.c
index b19ef38..8a96e43 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.c
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.c
@@ -435,6 +435,9 @@ enum ixgbe_phy_type ixgbe_get_phy_type_from_id(u32 phy_id)
case ATH_PHY_ID:
phy_type = ixgbe_phy_nl;
break;
+   case X557_PHY_ID:
+   phy_type = ixgbe_phy_x550em_ext_t;
+   break;
default:
phy_type = ixgbe_phy_unknown;
break;
diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h
index 77886df..459e0e3 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h
@@ -1390,10 +1390,17 @@ struct ixgbe_dmac_config {
 #define IXGBE_MDIO_PHY_100BASETX_ABILITY   0x0080 /* 100BaseTX capable */
 #define IXGBE_MDIO_PHY_SET_LOW_POWER_MODE  0x0800 /* Set low power mode */

+#define IXGBE_MDIO_TX_VENDOR_ALARMS_3  0xCC02 /* Vendor Alarms 3 Reg */
+#define IXGBE_MDIO_TX_VENDOR_ALARMS_3_RST_MASK 0x3 /* PHY Reset Complete Mask 
*/
+#define IXGBE_MDIO_GLOBAL_RES_PR_10 0xC479 /* Global Resv Provisioning 10 Reg 
*/
+#define IXGBE_MDIO_POWER_UP_STALL  0x8000 /* Power Up Stall */
+
 #define IXGBE_MDIO_PMA_PMD_CONTROL_ADDR0x /* PMA/PMD Control Reg */
 #define IXGBE_MDIO_PMA_PMD_SDA_SCL_ADDR0xC30A /* PHY_XS SDA/SCL Addr 
Reg */
 #define IXGBE_MDIO_PMA_PMD_SDA_SCL_DATA0xC30B /* PHY_XS SDA/SCL Data 
Reg */
 #define IXGBE_MDIO_PMA_PMD_SDA_SCL_STAT0xC30C /* PHY_XS SDA/SCL Status 
Reg */
+#define IXGBE_MDIO_PMD_STD_TX_DISABLE_CNTR 0x9 /* Standard Transmit Dis Reg */
+#define IXGBE_MDIO_PMD_GLOBAL_TX_DISABLE 0x0001 /* PMD Global Transmit Dis */

 #define IXGBE_PCRC8ECL 0x0E810 /* PCR CRC-8 Error Count Lo */
 #define IXGBE_PCRC8ECH 0x0E811 /* PCR CRC-8 Error Count Hi */
@@ -1441,6 +1448,7 @@ struct ixgbe_dmac_config {
 #define TNX_FW_REV 0xB
 #define X540_PHY_ID0x01540200
 #define X550_PHY_ID0x01540220
+#define X557_PHY_ID0x01540240
 #define AQ_FW_REV  0x20
 #define QT2022_PHY_ID  0x0043A400
 #define ATH_PHY_ID 0x03429050
@@ -3228,6 +3236,7 @@ enum ixgbe_phy_type {
ixgbe_phy_aq,
ixgbe_phy_x550em_kr,
ixgbe_phy_x550em_kx4,
+   ixgbe_phy_x550em_ext_t,
ixgbe_phy_cu_unknown,
ixgbe_phy_qt,
ixgbe_phy_xaui,
@@ -3577,6 +3586,7 @@ struct ixgbe_phy_operations {
s32 (*read_reg_mdi)(struct ixgbe_hw *, u32, u32, u16 *);
s32 (*write_reg_mdi)(struct ixgbe_hw *, u32, u32, u16);
s32 (*setup_link)(struct ixgbe_hw *);
+   s32 (*setup_internal_link)(struct ixgbe_hw *);
s32 (*setup_link_speed)(struct ixgbe_hw *, ixgbe_link_speed, bool);
s32 (*check_link)(struct ixgbe_hw *, ixgbe_link_speed *, bool *);
s32 (*get_firmware_version)(struct ixgbe_hw *, u16 *);
diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c
index 45315ec..c07e4e9 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c
@@ -184,8 +184,6 @@ s32 ixgbe_init_ops_X550EM(struct ixgbe_hw *hw)
ixgbe_get_supported_physical_layer_X550em;

/* PHY */
-   phy->ops.read_reg = ixgbe_read_phy_reg_x550em;
-   phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
phy->ops.init = ixgbe_init_phy_ops_X550em;
phy->ops.identify = ixgbe_identify_phy_x550em;
if (mac->ops.get_media_type(hw) != ixgbe_media_type_copper)
@@ -936,6 +934,11 @@ s32 ixgbe_init_phy_ops_X550em(struct ixgbe_hw *hw)
switch (hw->phy.type) {
case ixgbe_phy_x550em_kr:
phy->ops.setup_link = ixgbe_setup_kr_x550em;
+   phy->ops.read_reg = ixgbe_read_phy_reg_x550em;
+   phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
+   break;
+   case ixgbe_phy_x550em_ext_t:
+   phy->ops.setup_internal_link = ixgbe_setup_internal_phy_x550em;
break;
default:
break;
@@ -977,6 +980,13 @@ s32 ixgbe_reset_hw_X550em(struct ixgbe_hw *hw)
if (status == IXGBE_ERR_SFP_NOT_SUPPORTED)
return status;

+   /* start the external PHY */
+   if (hw->phy.type == ixgbe_phy_x550em_ext_t) {
+   status = ixgbe_init_ext_t_x550em(hw);
+   if (status)
+   return status;
+   }
+
/* Setup SFP module if 

[dpdk-dev] [PATCH 15/36] ixgbe base codes: Update macros

2015-02-12 Thread Ouyang Changchun
Update macros in ixgbe_type header files.

Signed-off-by: Changchun Ouyang 
---
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h | 59 +
 1 file changed, 53 insertions(+), 6 deletions(-)

diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h
index 38bf633..77886df 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h
@@ -1369,6 +1369,7 @@ struct ixgbe_dmac_config {

 #define IXGBE_MDIO_AUTO_NEG_CONTROL0x0 /* AUTO_NEG Control Reg */
 #define IXGBE_MDIO_AUTO_NEG_STATUS 0x1 /* AUTO_NEG Status Reg */
+#define IXGBE_MDIO_AUTO_NEG_VENDOR_STAT0xC800 /* AUTO_NEG Vendor 
Status Reg */
 #define IXGBE_MDIO_AUTO_NEG_ADVT   0x10 /* AUTO_NEG Advt Reg */
 #define IXGBE_MDIO_AUTO_NEG_LP 0x13 /* AUTO_NEG LP Status Reg */
 #define IXGBE_MDIO_AUTO_NEG_EEE_ADVT   0x3C /* AUTO_NEG EEE Advt Reg */
@@ -1403,6 +1404,21 @@ struct ixgbe_dmac_config {
 /* MII clause 22/28 definitions */
 #define IXGBE_MDIO_PHY_LOW_POWER_MODE  0x0800

+#define IXGBE_MDIO_XENPAK_LASI_STATUS  0x9005 /* XENPAK LASI Status 
register*/
+#define IXGBE_XENPAK_LASI_LINK_STATUS_ALARM0x1 /* Link Status Alarm change 
*/
+
+#define IXGBE_MDIO_AUTO_NEG_LINK_STATUS0x4 /* Indicates if 
link is up */
+
+#define IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_MASK 0x7 /* Speed/Duplex 
Mask */
+#define IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_10M_HALF 0x0 /* 10Mb/s Half 
Duplex */
+#define IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_10M_FULL 0x1 /* 10Mb/s Full 
Duplex */
+#define IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_100M_HALF0x2 /* 100Mb/s Half 
Duplex */
+#define IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_100M_FULL0x3 /* 100Mb/s Full 
Duplex */
+#define IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_1GB_HALF 0x4 /* 1Gb/s Half 
Duplex */
+#define IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_1GB_FULL 0x5 /* 1Gb/s Full 
Duplex */
+#define IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_10GB_HALF0x6 /* 10Gb/s Half 
Duplex */
+#define IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_10GB_FULL0x7 /* 10Gb/s Full 
Duplex */
+
 #define IXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG   0x20   /* 10G Control Reg */
 #define IXGBE_MII_AUTONEG_VENDOR_PROVISION_1_REG 0xC400 /* 1G Provisioning 1 */
 #define IXGBE_MII_AUTONEG_XNP_TX_REG   0x17   /* 1G XNP Transmit */
@@ -1448,6 +1464,15 @@ struct ixgbe_dmac_config {
 #define IXGBE_SDP0_GPIEN   0x0001 /* SDP0 */
 #define IXGBE_SDP1_GPIEN   0x0002 /* SDP1 */
 #define IXGBE_SDP2_GPIEN   0x0004 /* SDP2 */
+#define IXGBE_SDP0_GPIEN_X540  0x0002 /* SDP0 on X540 and X550 */
+#define IXGBE_SDP1_GPIEN_X540  0x0004 /* SDP1 on X540 and X550 */
+#define IXGBE_SDP2_GPIEN_X540  0x0008 /* SDP2 on X540 and X550 */
+#define IXGBE_SDP0_GPIEN_BY_MAC(_hw) ((_hw)->mac.type >= ixgbe_mac_X540 ? \
+ IXGBE_SDP0_GPIEN_X540 : IXGBE_SDP0_GPIEN)
+#define IXGBE_SDP1_GPIEN_BY_MAC(_hw) ((_hw)->mac.type >= ixgbe_mac_X540 ? \
+ IXGBE_SDP1_GPIEN_X540 : IXGBE_SDP1_GPIEN)
+#define IXGBE_SDP2_GPIEN_BY_MAC(_hw) ((_hw)->mac.type >= ixgbe_mac_X540 ? \
+ IXGBE_SDP2_GPIEN_X540 : IXGBE_SDP2_GPIEN)
 #define IXGBE_GPIE_MSIX_MODE   0x0010 /* MSI-X mode */
 #define IXGBE_GPIE_OCD 0x0020 /* Other Clear Disable */
 #define IXGBE_GPIE_EIMEN   0x0040 /* Immediate Interrupt Enable */
@@ -1625,6 +1650,18 @@ enum {
 #define IXGBE_EICR_GPI_SDP10x0200 /* Gen Purpose Interrupt on SDP1 */
 #define IXGBE_EICR_GPI_SDP20x0400 /* Gen Purpose Interrupt on SDP2 */
 #define IXGBE_EICR_ECC 0x1000 /* ECC Error */
+#define IXGBE_EICR_GPI_SDP0_X540 0x0200 /* Gen Purpose Interrupt on SDP0 */
+#define IXGBE_EICR_GPI_SDP1_X540 0x0400 /* Gen Purpose Interrupt on SDP1 */
+#define IXGBE_EICR_GPI_SDP2_X540 0x0800 /* Gen Purpose Interrupt on SDP2 */
+#define IXGBE_EICR_GPI_SDP0_BY_MAC(_hw)((_hw)->mac.type >= 
ixgbe_mac_X540 ? \
+IXGBE_EICR_GPI_SDP0_X540 : \
+IXGBE_EICR_GPI_SDP0)
+#define IXGBE_EICR_GPI_SDP1_BY_MAC(_hw)((_hw)->mac.type >= 
ixgbe_mac_X540 ? \
+IXGBE_EICR_GPI_SDP1_X540 : \
+IXGBE_EICR_GPI_SDP1)
+#define IXGBE_EICR_GPI_SDP2_BY_MAC(_hw)((_hw)->mac.type >= 
ixgbe_mac_X540 ? \
+IXGBE_EICR_GPI_SDP2_X540 : \
+IXGBE_EICR_GPI_SDP2)
 #define IXGBE_EICR_PBUR0x1000 /* Packet Buffer Handler 
Error */
 #define IXGBE_EICR_DHER0x2000 /* Descriptor Handler Error 
*/
 #define IXGBE_EICR_TCP_TIMER   0x4000 /* TCP Timer */
@@ -1643,6 +1680,9 @@ enum {
 #define IXGBE_EICS_GPI_SDP1IXGBE_EICR_GPI_SDP1 /* SDP1 Gen Purpose Int */
 #define IXGBE_EICS_GPI_SDP2IXGBE_EICR_GPI_SDP2 /* SDP2 Gen Purpose 

[dpdk-dev] [PATCH 14/36] ixgbe base codes: Use IOMEM

2015-02-12 Thread Ouyang Changchun
Use IOMEM for hw addr.

Signed-off-by: Changchun Ouyang 
---
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_osdep.h | 2 ++
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h  | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_osdep.h 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_osdep.h
index eeb08a8..c041c1d 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_osdep.h
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_osdep.h
@@ -113,6 +113,8 @@ typedef int bool;
 #define wmb()  rte_wmb()
 #define rmb()  rte_rmb()

+#define IOMEM
+
 #define prefetch(x) rte_prefetch0(x)

 #define IXGBE_PCI_REG(reg) (*((volatile uint32_t *)(reg)))
diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h
index 23e45c2..38bf633 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h
@@ -3641,7 +3641,7 @@ struct ixgbe_mbx_info {
 };

 struct ixgbe_hw {
-   u8 *hw_addr;
+   u8 IOMEM *hw_addr;
void *back;
struct ixgbe_mac_info mac;
struct ixgbe_addr_filter_info addr_ctrl;
-- 
1.8.4.2



[dpdk-dev] [PATCH 13/36] ixgbe base codes: Clear Tx pending

2015-02-12 Thread Ouyang Changchun
Wait for a last completion before clearing buffers,
and before proceeding, it needs make sure that the PCIe block does not have
transactions pending.

Signed-off-by: Changchun Ouyang 
---
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.c | 22 +-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.c 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.c
index 8cdc385..5667216 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.c
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.c
@@ -4612,7 +4612,8 @@ void ixgbe_set_rxpba_generic(struct ixgbe_hw *hw, int 
num_pb, u32 headroom,
  **/
 void ixgbe_clear_tx_pending(struct ixgbe_hw *hw)
 {
-   u32 gcr_ext, hlreg0;
+   u32 gcr_ext, hlreg0, i, poll;
+   u16 value;

/*
 * If double reset is not requested then all transactions should
@@ -4629,6 +4630,25 @@ void ixgbe_clear_tx_pending(struct ixgbe_hw *hw)
hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0);
IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0 | IXGBE_HLREG0_LPBK);

+   /* Wait for a last completion before clearing buffers */
+   IXGBE_WRITE_FLUSH(hw);
+   msec_delay(3);
+
+   /*
+* Before proceeding, make sure that the PCIe block does not have
+* transactions pending.
+*/
+   poll = ixgbe_pcie_timeout_poll(hw);
+   for (i = 0; i < poll; i++) {
+   usec_delay(100);
+   value = IXGBE_READ_PCIE_WORD(hw, IXGBE_PCI_DEVICE_STATUS);
+   if (IXGBE_REMOVED(hw->hw_addr))
+   goto out;
+   if (!(value & IXGBE_PCI_DEVICE_STATUS_TRANSACTION_PENDING))
+   goto out;
+   }
+
+out:
/* initiate cleaning flow for buffers in the PCIe transaction layer */
gcr_ext = IXGBE_READ_REG(hw, IXGBE_GCR_EXT);
IXGBE_WRITE_REG(hw, IXGBE_GCR_EXT,
-- 
1.8.4.2



[dpdk-dev] [PATCH 12/36] ixgbe base codes: Refine struct for physical information

2015-02-12 Thread Ouyang Changchun
Remove lan_id from struct ixgbe_phy_info.

Signed-off-by: Changchun Ouyang 
---
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.c  |  4 +-
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h |  1 -
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_x540.c |  2 +-
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c | 66 -
 4 files changed, 34 insertions(+), 39 deletions(-)

diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.c 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.c
index a1144d4..b19ef38 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.c
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.c
@@ -283,9 +283,7 @@ s32 ixgbe_identify_phy_generic(struct ixgbe_hw *hw)
DEBUGFUNC("ixgbe_identify_phy_generic");

if (!hw->phy.phy_semaphore_mask) {
-   hw->phy.lan_id = IXGBE_READ_REG(hw, IXGBE_STATUS) &
-   IXGBE_STATUS_LAN_ID_1;
-   if (hw->phy.lan_id)
+   if (hw->bus.lan_id)
hw->phy.phy_semaphore_mask = IXGBE_GSSR_PHY1_SM;
else
hw->phy.phy_semaphore_mask = IXGBE_GSSR_PHY0_SM;
diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h
index cac6387..23e45c2 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h
@@ -3600,7 +3600,6 @@ struct ixgbe_phy_info {
u32 revision;
enum ixgbe_media_type media_type;
u32 phy_semaphore_mask;
-   u8 lan_id;
bool reset_disable;
ixgbe_autoneg_advertised autoneg_advertised;
enum ixgbe_smart_speed smart_speed;
diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x540.c 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x540.c
index c2d685f..6e8835d 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x540.c
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x540.c
@@ -747,7 +747,7 @@ STATIC void ixgbe_set_mux(struct ixgbe_hw *hw, u8 state)
 {
u32 esdp;

-   if (!hw->phy.lan_id)
+   if (!hw->bus.lan_id)
return;
esdp = IXGBE_READ_REG(hw, IXGBE_ESDP);
if (state)
diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c
index 3c76c3d..45315ec 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c
@@ -94,10 +94,8 @@ STATIC s32 ixgbe_identify_phy_x550em(struct ixgbe_hw *hw)
switch (hw->device_id) {
case IXGBE_DEV_ID_X550EM_X_SFP:
/* set up for CS4227 usage */
-   hw->phy.lan_id = IXGBE_READ_REG(hw, IXGBE_STATUS) &
-IXGBE_STATUS_LAN_ID_1;
hw->phy.phy_semaphore_mask = IXGBE_GSSR_SHARED_I2C_SM;
-   if (hw->phy.lan_id) {
+   if (hw->bus.lan_id) {

esdp &= ~(IXGBE_ESDP_SDP1_NATIVE | IXGBE_ESDP_SDP1);
esdp |= IXGBE_ESDP_SDP1_DIR;
@@ -407,7 +405,7 @@ s32 ixgbe_setup_eee_X550(struct ixgbe_hw *hw, bool 
enable_eee)
} else if (hw->device_id == IXGBE_DEV_ID_X550EM_X_KR ||
   hw->device_id == IXGBE_DEV_ID_X550EM_X) {
status = ixgbe_read_iosf_sb_reg_x550(hw,
-   IXGBE_KRM_LINK_CTRL_1(hw->phy.lan_id),
+   IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
IXGBE_SB_IOSF_TARGET_KR_PHY, _reg);
if (status != IXGBE_SUCCESS)
return status;
@@ -416,7 +414,7 @@ s32 ixgbe_setup_eee_X550(struct ixgbe_hw *hw, bool 
enable_eee)
IXGBE_KRM_LINK_CTRL_1_TETH_EEE_CAP_KX;

status = ixgbe_write_iosf_sb_reg_x550(hw,
-   IXGBE_KRM_LINK_CTRL_1(hw->phy.lan_id),
+   IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
IXGBE_SB_IOSF_TARGET_KR_PHY, link_reg);
if (status != IXGBE_SUCCESS)
return status;
@@ -438,7 +436,7 @@ s32 ixgbe_setup_eee_X550(struct ixgbe_hw *hw, bool 
enable_eee)
} else if (hw->device_id == IXGBE_DEV_ID_X550EM_X_KR ||
   hw->device_id == IXGBE_DEV_ID_X550EM_X) {
status = ixgbe_read_iosf_sb_reg_x550(hw,
-   IXGBE_KRM_LINK_CTRL_1(hw->phy.lan_id),
+   IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
IXGBE_SB_IOSF_TARGET_KR_PHY, _reg);
if (status != IXGBE_SUCCESS)
return status;
@@ -447,7 +445,7 @@ s32 ixgbe_setup_eee_X550(struct ixgbe_hw *hw, bool 
enable_eee)
IXGBE_KRM_LINK_CTRL_1_TETH_EEE_CAP_KX);

status = ixgbe_write_iosf_sb_reg_x550(hw,
-   IXGBE_KRM_LINK_CTRL_1(hw->phy.lan_id),
+   

[dpdk-dev] [PATCH 11/36] ixgbe base codes: Refine function for host interface command

2015-02-12 Thread Ouyang Changchun
Add timeout as new argument in host interface command.

Signed-off-by: Changchun Ouyang 
---
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.c | 13 -
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.h |  2 +-
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h   |  5 -
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c   | 15 ++-
 4 files changed, 23 insertions(+), 12 deletions(-)

diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.c 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.c
index d8d2ea3..8cdc385 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.c
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.c
@@ -4376,6 +4376,7 @@ s32 ixgbe_get_hi_status(struct ixgbe_hw *hw, u8 
*ret_status)
  *  @buffer: contains the command to write and where the return status will
  *   be placed
  *  @length: length of buffer, must be multiple of 4 bytes
+ *  @timeout: time in ms to wait for command completion
  *  @return_data: read and return data from the buffer (true) or not (false)
  *   Needed because FW structures are big endian and decoding of
  *   these fields can be 8 bit or 16 bit based on command. Decoding
@@ -4387,12 +4388,12 @@ s32 ixgbe_get_hi_status(struct ixgbe_hw *hw, u8 
*ret_status)
  *  else return IXGBE_ERR_HOST_INTERFACE_COMMAND.
  **/
 s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 *buffer,
-u32 length, bool return_data)
+u32 length, u32 timeout, bool return_data)
 {
u32 hicr, i, bi, fwsts;
u32 hdr_size = sizeof(struct ixgbe_hic_hdr);
u16 buf_len;
-   u8 dword_len;
+   u16 dword_len;

DEBUGFUNC("ixgbe_host_interface_command");

@@ -4429,7 +4430,7 @@ s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 
*buffer,
/* Setting this bit tells the ARC that a new command is pending. */
IXGBE_WRITE_REG(hw, IXGBE_HICR, hicr | IXGBE_HICR_C);

-   for (i = 0; i < IXGBE_HI_COMMAND_TIMEOUT; i++) {
+   for (i = 0; i < timeout; i++) {
hicr = IXGBE_READ_REG(hw, IXGBE_HICR);
if (!(hicr & IXGBE_HICR_C))
break;
@@ -4437,7 +4438,7 @@ s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 
*buffer,
}

/* Check command completion */
-   if (i == IXGBE_HI_COMMAND_TIMEOUT ||
+   if ((timeout != 0 && i == timeout) ||
!(IXGBE_READ_REG(hw, IXGBE_HICR) & IXGBE_HICR_SV)) {
ERROR_REPORT1(IXGBE_ERROR_CAUTION,
 "Command has failed with no status valid.\n");
@@ -4522,7 +4523,9 @@ s32 ixgbe_set_fw_drv_ver_generic(struct ixgbe_hw *hw, u8 
maj, u8 min,

for (i = 0; i <= FW_CEM_MAX_RETRIES; i++) {
ret_val = ixgbe_host_interface_command(hw, (u32 *)_cmd,
-  sizeof(fw_cmd), true);
+  sizeof(fw_cmd),
+  IXGBE_HI_COMMAND_TIMEOUT,
+  true);
if (ret_val != IXGBE_SUCCESS)
continue;

diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.h 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.h
index c2e28f2..9ebdd45 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.h
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.h
@@ -157,7 +157,7 @@ s32 ixgbe_set_fw_drv_ver_generic(struct ixgbe_hw *hw, u8 
maj, u8 min,
 u8 ixgbe_calculate_checksum(u8 *buffer, u32 length);
 s32 ixgbe_get_hi_status(struct ixgbe_hw *hw, u8 *ret_status);
 s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 *buffer,
-u32 length, bool return_data);
+u32 length, u32 timeout, bool return_data);

 void ixgbe_clear_tx_pending(struct ixgbe_hw *hw);

diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h
index 88ab4b0..cac6387 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h
@@ -74,7 +74,7 @@ POSSIBILITY OF SUCH DAMAGE.

 #include "ixgbe_osdep.h"

-#ident "$Id: ixgbe_type.h,v 1.630 2013/11/22 22:48:40 jtkirshe Exp $"
+/* Override this by setting IOMEM in your ixgbe_osdep.h header */

 /* Vendor ID */
 #define IXGBE_INTEL_VENDOR_ID  0x8086
@@ -2731,6 +2731,9 @@ enum ixgbe_fdir_pballoc_type {
 #define IXGBE_HI_MAX_BLOCK_BYTE_LENGTH 1792 /* Num of bytes in range */
 #define IXGBE_HI_MAX_BLOCK_DWORD_LENGTH448 /* Num of dwords in range */
 #define IXGBE_HI_COMMAND_TIMEOUT   500 /* Process HI command limit */
+#define IXGBE_HI_FLASH_ERASE_TIMEOUT   1000 /* Process Erase command limit */
+#define IXGBE_HI_FLASH_UPDATE_TIMEOUT  5000 /* Process Update command limit */
+#define IXGBE_HI_FLASH_APPLY_TIMEOUT   0 /* Process Apply command limit */

 /* CEM Support */
 #define FW_CEM_HDR_LEN 0x4
diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c 

[dpdk-dev] [PATCH 09/36] ixgbe base codes: Use mng present function

2015-02-12 Thread Ouyang Changchun
82599 use mng present to check if MNG FW could be enabled.

Signed-off-by: Changchun Ouyang 
---
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_82599.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_82599.c 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_82599.c
index f52ffa2..9844894 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_82599.c
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_82599.c
@@ -578,17 +578,13 @@ out:
  **/
 void ixgbe_stop_mac_link_on_d3_82599(struct ixgbe_hw *hw)
 {
-   u32 autoc2_reg, fwsm;
+   u32 autoc2_reg;
u16 ee_ctrl_2 = 0;

DEBUGFUNC("ixgbe_stop_mac_link_on_d3_82599");
ixgbe_read_eeprom(hw, IXGBE_EEPROM_CTRL_2, _ctrl_2);

-   /* Check to see if MNG FW could be enabled */
-   fwsm = IXGBE_READ_REG(hw, IXGBE_FWSM);
-
-   if (((fwsm & IXGBE_FWSM_MODE_MASK) != IXGBE_FWSM_FW_MODE_PT) &&
-   !hw->wol_enabled &&
+   if (!ixgbe_mng_present(hw) && !hw->wol_enabled &&
ee_ctrl_2 & IXGBE_EEPROM_CCD_BIT) {
autoc2_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC2);
autoc2_reg |= IXGBE_AUTOC2_LINK_DISABLE_ON_D3_MASK;
-- 
1.8.4.2



[dpdk-dev] [PATCH 08/36] ixgbe base codes: Set phy power

2015-02-12 Thread Ouyang Changchun
Define the function of setting phy power;
Set copper phy power for x540.

Signed-off-by: Changchun Ouyang 
---
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.c  | 30 ++
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.h  |  1 +
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h |  1 +
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_x540.c |  2 ++
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c |  7 ---
 5 files changed, 38 insertions(+), 3 deletions(-)

diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.c 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.c
index 0c0b084..a1144d4 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.c
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.c
@@ -2420,3 +2420,33 @@ s32 ixgbe_tn_check_overtemp(struct ixgbe_hw *hw)
 out:
return status;
 }
+
+/**
+ * ixgbe_set_copper_phy_power - Control power for copper phy
+ * @hw: pointer to hardware structure
+ * @on: true for on, false for off
+ */
+s32 ixgbe_set_copper_phy_power(struct ixgbe_hw *hw, bool on)
+{
+   u32 status;
+   u16 reg;
+
+   status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_VENDOR_SPECIFIC_1_CONTROL,
+ IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
+ );
+   if (status)
+   return status;
+
+   if (on) {
+   reg &= ~IXGBE_MDIO_PHY_SET_LOW_POWER_MODE;
+   } else {
+   if (ixgbe_check_reset_blocked(hw))
+   return 0;
+   reg |= IXGBE_MDIO_PHY_SET_LOW_POWER_MODE;
+   }
+
+   status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_VENDOR_SPECIFIC_1_CONTROL,
+  IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
+  reg);
+   return status;
+}
diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.h 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.h
index 1796fbf..805b9f9 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.h
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.h
@@ -156,6 +156,7 @@ s32 ixgbe_get_phy_firmware_version_generic(struct ixgbe_hw 
*hw,
   u16 *firmware_version);

 s32 ixgbe_reset_phy_nl(struct ixgbe_hw *hw);
+s32 ixgbe_set_copper_phy_power(struct ixgbe_hw *hw, bool on);
 s32 ixgbe_identify_module_generic(struct ixgbe_hw *hw);
 s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw);
 s32 ixgbe_get_supported_phy_sfp_layer_generic(struct ixgbe_hw *hw);
diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h
index c67d462..88ab4b0 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h
@@ -3539,6 +3539,7 @@ struct ixgbe_phy_operations {
s32 (*read_i2c_combined)(struct ixgbe_hw *, u8 addr, u16 reg, u16 *val);
s32 (*write_i2c_combined)(struct ixgbe_hw *, u8 addr, u16 reg, u16 val);
s32 (*check_overtemp)(struct ixgbe_hw *);
+   s32 (*set_phy_power)(struct ixgbe_hw *, bool on);
 };

 struct ixgbe_eeprom_info {
diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x540.c 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x540.c
index 3ab2184..c2d685f 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x540.c
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x540.c
@@ -81,6 +81,8 @@ s32 ixgbe_init_ops_X540(struct ixgbe_hw *hw)
/* PHY */
phy->ops.init = ixgbe_init_phy_ops_generic;
phy->ops.reset = NULL;
+   if (!ixgbe_mng_present(hw))
+   phy->ops.set_phy_power = ixgbe_set_copper_phy_power;

/* MAC */
mac->ops.reset_hw = ixgbe_reset_hw_X540;
diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c
index a2a6652..1445f52 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c
@@ -186,11 +186,12 @@ s32 ixgbe_init_ops_X550EM(struct ixgbe_hw *hw)
ixgbe_get_supported_physical_layer_X550em;

/* PHY */
-   phy->ops.init = _init_phy_ops_X550em;
-   phy->ops.identify = _identify_phy_x550em;
phy->ops.read_reg = ixgbe_read_phy_reg_x550em;
phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
-   phy->ops.setup_link = ixgbe_setup_kr_x550em;
+   phy->ops.init = ixgbe_init_phy_ops_X550em;
+   phy->ops.identify = ixgbe_identify_phy_x550em;
+   if (mac->ops.get_media_type(hw) != ixgbe_media_type_copper)
+   phy->ops.set_phy_power = NULL;


/* EEPROM */
-- 
1.8.4.2



[dpdk-dev] [PATCH 07/36] ixgbe base codes: Extract function for management capability

2015-02-12 Thread Ouyang Changchun
Define function ixgbe_mng_present to check if management capability is present 
or not.

Signed-off-by: Changchun Ouyang 
---
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.c | 16 
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.h |  1 +
 2 files changed, 17 insertions(+)

diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.c 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.c
index 28eb3eb..f0e35f4 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.c
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.c
@@ -4839,6 +4839,22 @@ void ixgbe_enable_rx_generic(struct ixgbe_hw *hw)
 }

 /**
+ * ixgbe_mng_present - returns true when management capability is present
+ * @hw: pointer to hardware structure
+ */
+bool ixgbe_mng_present(struct ixgbe_hw *hw)
+{
+   u32 fwsm;
+
+   if (hw->mac.type < ixgbe_mac_82599EB)
+   return false;
+
+   fwsm = IXGBE_READ_REG(hw, IXGBE_FWSM);
+   fwsm &= IXGBE_FWSM_MODE_MASK;
+   return fwsm == IXGBE_FWSM_FW_MODE_PT;
+}
+
+/**
  * ixgbe_mng_enabled - Is the manageability engine enabled?
  * @hw: pointer to hardware structure
  *
diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.h 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.h
index 3598261..f2418f3 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.h
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.h
@@ -162,6 +162,7 @@ void ixgbe_clear_tx_pending(struct ixgbe_hw *hw);

 extern s32 ixgbe_reset_pipeline_82599(struct ixgbe_hw *hw);
 extern void ixgbe_stop_mac_link_on_d3_82599(struct ixgbe_hw *hw);
+bool ixgbe_mng_present(struct ixgbe_hw *hw);
 bool ixgbe_mng_enabled(struct ixgbe_hw *hw);

 #define IXGBE_I2C_THERMAL_SENSOR_ADDR  0xF8
-- 
1.8.4.2



[dpdk-dev] [PATCH 06/36] ixgbe base codes: Update the CS address

2015-02-12 Thread Ouyang Changchun
Update the adress of IXGBE_CS4227.

Signed-off-by: Changchun Ouyang 
---
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.h  | 2 +-
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.h 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.h
index e262cc4..1796fbf 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.h
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.h
@@ -82,7 +82,7 @@ POSSIBILITY OF SUCH DAMAGE.
 #define IXGBE_I2C_EEPROM_STATUS_FAIL   0x2
 #define IXGBE_I2C_EEPROM_STATUS_IN_PROGRESS0x3

-#define IXGBE_CS4227   0x9E/* CS4227 address */
+#define IXGBE_CS4227   0xBE/* CS4227 address */
 #define IXGBE_CS4227_SPARE24_LSB   0x12B0  /* Reg to program EDC */
 #define IXGBE_CS4227_EDC_MODE_CX1  0x0002
 #define IXGBE_CS4227_EDC_MODE_SR   0x0004
diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c
index 84ab8b7..a2a6652 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c
@@ -819,7 +819,7 @@ s32 ixgbe_setup_sfp_modules_X550em(struct ixgbe_hw *hw)
hw->phy.ops.reset = NULL;

/* The CS4227 slice address is the base address + the port-pair reg
-* offset. I.e. Slice 0 = 0x and slice 1 = 0x1000.
+* offset. I.e. Slice 0 = 0x12B0 and slice 1 = 0x22B0.
 */
reg_slice = IXGBE_CS4227_SPARE24_LSB + (hw->phy.lan_id << 12);

-- 
1.8.4.2



[dpdk-dev] [PATCH 05/36] ixgbe base codes: Fix early return

2015-02-12 Thread Ouyang Changchun
It could early return according to read status.

Signed-off-by: Changchun Ouyang 
---
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c
index 76e9a32..84ab8b7 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c
@@ -1060,6 +1060,8 @@ s32 ixgbe_setup_kr_x550em(struct ixgbe_hw *hw)
status = ixgbe_read_iosf_sb_reg_x550(hw,
IXGBE_KRM_LINK_CTRL_1(hw->phy.lan_id),
IXGBE_SB_IOSF_TARGET_KR_PHY, _val);
+   if (status)
+   return status;

reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_FEC_REQ;
-- 
1.8.4.2



[dpdk-dev] [PATCH 04/36] ixgbe base codes: Fix link speed issue

2015-02-12 Thread Ouyang Changchun
Remove unnecessary '|' for the link speed.

Signed-off-by: Changchun Ouyang 
---
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c
index 540b477..76e9a32 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c
@@ -882,13 +882,13 @@ s32 ixgbe_get_link_capabilities_X550em(struct ixgbe_hw 
*hw,

/* Link capabilities are based on SFP */
if (hw->phy.multispeed_fiber)
-   *speed |= IXGBE_LINK_SPEED_10GB_FULL |
- IXGBE_LINK_SPEED_1GB_FULL;
+   *speed = IXGBE_LINK_SPEED_10GB_FULL |
+IXGBE_LINK_SPEED_1GB_FULL;
else
*speed = IXGBE_LINK_SPEED_10GB_FULL;
} else {
-   *speed |= IXGBE_LINK_SPEED_10GB_FULL |
- IXGBE_LINK_SPEED_1GB_FULL;
+   *speed = IXGBE_LINK_SPEED_10GB_FULL |
+IXGBE_LINK_SPEED_1GB_FULL;
*autoneg = true;
}

-- 
1.8.4.2



[dpdk-dev] [PATCH 03/36] ixgbe base codes: Fix bus type issue

2015-02-12 Thread Ouyang Changchun
It needs check if the bus type is the unknown type or not.

Signed-off-by: Changchun Ouyang 
---
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.c 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.c
index 38a5a2a..28eb3eb 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.c
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.c
@@ -953,7 +953,8 @@ void ixgbe_set_pci_config_data_generic(struct ixgbe_hw *hw, 
u16 link_status)
 {
struct ixgbe_mac_info *mac = >mac;

-   hw->bus.type = ixgbe_bus_type_pci_express;
+   if (hw->bus.type == ixgbe_bus_type_unknown)
+   hw->bus.type = ixgbe_bus_type_pci_express;

switch (link_status & IXGBE_PCI_LINK_WIDTH) {
case IXGBE_PCI_LINK_WIDTH_1:
-- 
1.8.4.2



[dpdk-dev] [PATCH 02/36] ixgbe base codes: Debug output macro

2015-02-12 Thread Ouyang Changchun
Use DEBUGOUT to replace ERROR_REPORT1.

Signed-off-by: Changchun Ouyang 
---
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.c 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.c
index 1f536e1..38a5a2a 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.c
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.c
@@ -2899,8 +2899,7 @@ STATIC s32 ixgbe_fc_autoneg_fiber(struct ixgbe_hw *hw)
linkstat = IXGBE_READ_REG(hw, IXGBE_PCS1GLSTA);
if ((!!(linkstat & IXGBE_PCS1GLSTA_AN_COMPLETE) == 0) ||
(!!(linkstat & IXGBE_PCS1GLSTA_AN_TIMED_OUT) == 1)) {
-   ERROR_REPORT1(IXGBE_ERROR_POLLING,
-"Auto-Negotiation did not complete or timed out");
+   DEBUGOUT("Auto-Negotiation did not complete or timed out\n");
goto out;
}

@@ -2935,16 +2934,14 @@ STATIC s32 ixgbe_fc_autoneg_backplane(struct ixgbe_hw 
*hw)
 */
links = IXGBE_READ_REG(hw, IXGBE_LINKS);
if ((links & IXGBE_LINKS_KX_AN_COMP) == 0) {
-   ERROR_REPORT1(IXGBE_ERROR_POLLING,
-"Auto-Negotiation did not complete");
+   DEBUGOUT("Auto-Negotiation did not complete\n");
goto out;
}

if (hw->mac.type == ixgbe_mac_82599EB) {
links2 = IXGBE_READ_REG(hw, IXGBE_LINKS2);
if ((links2 & IXGBE_LINKS2_AN_SUPPORTED) == 0) {
-   ERROR_REPORT1(IXGBE_ERROR_UNSUPPORTED,
-"Link partner is not AN enabled");
+   DEBUGOUT("Link partner is not AN enabled\n");
goto out;
}
}
-- 
1.8.4.2



[dpdk-dev] [PATCH 01/36] ixgbe base codes: Code cleanup and minor changes

2015-02-12 Thread Ouyang Changchun
Remove '&' before function name;
Adjust the spaces etc.

Signed-off-by: Changchun Ouyang 
---
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_82598.c |  55 +++---
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_82598.h |   1 -
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_82599.c | 105 +--
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_82599.h |   1 -
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.c   |   1 -
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.h   |   1 -
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.c|  73 +--
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.h|   1 -
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_dcb.c   |   1 -
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_dcb.h   |   2 -
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_dcb_82598.c |   1 -
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_dcb_82598.h |   1 -
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_dcb_82599.c |   1 -
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_dcb_82599.h |   1 -
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_osdep.h |   2 +-
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.c   |  37 +-
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_vf.c|   1 -
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_vf.h|   5 --
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_x540.c  |  78 ++--
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_x540.h  |   1 -
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c  |  73 +--
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.h  |   3 +-
 22 files changed, 210 insertions(+), 235 deletions(-)

diff --git a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_82598.c 
b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_82598.c
index c8ce893..4e06550 100644
--- a/lib/librte_pmd_ixgbe/ixgbe/ixgbe_82598.c
+++ b/lib/librte_pmd_ixgbe/ixgbe/ixgbe_82598.c
@@ -36,7 +36,6 @@ POSSIBILITY OF SUCH DAMAGE.
 #include "ixgbe_api.h"
 #include "ixgbe_common.h"
 #include "ixgbe_phy.h"
-#ident "$Id: ixgbe_82598.c,v 1.199 2013/05/22 23:26:31 jtkirshe Exp $"

 #define IXGBE_82598_MAX_TX_QUEUES 32
 #define IXGBE_82598_MAX_RX_QUEUES 64
@@ -128,29 +127,29 @@ s32 ixgbe_init_ops_82598(struct ixgbe_hw *hw)
ret_val = ixgbe_init_ops_generic(hw);

/* PHY */
-   phy->ops.init = _init_phy_ops_82598;
+   phy->ops.init = ixgbe_init_phy_ops_82598;

/* MAC */
-   mac->ops.start_hw = _start_hw_82598;
-   mac->ops.enable_relaxed_ordering = _enable_relaxed_ordering_82598;
-   mac->ops.reset_hw = _reset_hw_82598;
-   mac->ops.get_media_type = _get_media_type_82598;
+   mac->ops.start_hw = ixgbe_start_hw_82598;
+   mac->ops.enable_relaxed_ordering = ixgbe_enable_relaxed_ordering_82598;
+   mac->ops.reset_hw = ixgbe_reset_hw_82598;
+   mac->ops.get_media_type = ixgbe_get_media_type_82598;
mac->ops.get_supported_physical_layer =
-   _get_supported_physical_layer_82598;
-   mac->ops.read_analog_reg8 = _read_analog_reg8_82598;
-   mac->ops.write_analog_reg8 = _write_analog_reg8_82598;
-   mac->ops.set_lan_id = _set_lan_id_multi_port_pcie_82598;
-   mac->ops.enable_rx_dma = _enable_rx_dma_82598;
+   ixgbe_get_supported_physical_layer_82598;
+   mac->ops.read_analog_reg8 = ixgbe_read_analog_reg8_82598;
+   mac->ops.write_analog_reg8 = ixgbe_write_analog_reg8_82598;
+   mac->ops.set_lan_id = ixgbe_set_lan_id_multi_port_pcie_82598;
+   mac->ops.enable_rx_dma = ixgbe_enable_rx_dma_82598;

/* RAR, Multicast, VLAN */
-   mac->ops.set_vmdq = _set_vmdq_82598;
-   mac->ops.clear_vmdq = _clear_vmdq_82598;
-   mac->ops.set_vfta = _set_vfta_82598;
+   mac->ops.set_vmdq = ixgbe_set_vmdq_82598;
+   mac->ops.clear_vmdq = ixgbe_clear_vmdq_82598;
+   mac->ops.set_vfta = ixgbe_set_vfta_82598;
mac->ops.set_vlvf = NULL;
-   mac->ops.clear_vfta = _clear_vfta_82598;
+   mac->ops.clear_vfta = ixgbe_clear_vfta_82598;

/* Flow Control */
-   mac->ops.fc_enable = _fc_enable_82598;
+   mac->ops.fc_enable = ixgbe_fc_enable_82598;

mac->mcft_size  = IXGBE_82598_MC_TBL_SIZE;
mac->vft_size   = IXGBE_82598_VFT_TBL_SIZE;
@@ -161,15 +160,15 @@ s32 ixgbe_init_ops_82598(struct ixgbe_hw *hw)
mac->max_msix_vectors   = ixgbe_get_pcie_msix_count_generic(hw);

/* SFP+ Module */
-   phy->ops.read_i2c_eeprom = _read_i2c_eeprom_82598;
-   phy->ops.read_i2c_sff8472 = _read_i2c_sff8472_82598;
+   phy->ops.read_i2c_eeprom = ixgbe_read_i2c_eeprom_82598;
+   phy->ops.read_i2c_sff8472 = ixgbe_read_i2c_sff8472_82598;

/* Link */
-   mac->ops.check_link = _check_mac_link_82598;
-   mac->ops.setup_link = _setup_mac_link_82598;
+   mac->ops.check_link = ixgbe_check_mac_link_82598;
+   mac->ops.setup_link = ixgbe_setup_mac_link_82598;
mac->ops.flap_tx_laser = NULL;
-   mac->ops.get_link_capabilities = _get_link_capabilities_82598;
-   mac->ops.setup_rxpba = _set_rxpba_82598;
+   mac->ops.get_link_capabilities = ixgbe_get_link_capabilities_82598;
+   mac->ops.setup_rxpba = 

[dpdk-dev] [PATCH 00/36] Update IXGBE base codes

2015-02-12 Thread Ouyang Changchun
This patch set update IXGBE base codes to the version of 
cid-10g-shared-code.2015.02.03.
and this patch set add 2 new device id as following:
#define IXGBE_DEV_ID_X550EM_X_10G_T0x15AD
#define IXGBE_DEV_ID_X550EM_X_1G_T 0x15AE

Changchun Ouyang (36):
  ixgbe base codes: Code cleanup and minor changes
  ixgbe base codes: Debug output macro
  ixgbe base codes: Fix bus type issue
  ixgbe base codes: Fix link speed issue
  ixgbe base codes: Fix early return
  ixgbe base codes: Update the CS address
  ixgbe base codes: Extract function for management capability
  ixgbe base codes: Set phy power
  ixgbe base codes: Use mng present function
  ixgbe base codes: Get host interface command status
  ixgbe base codes: Refine function for host interface command
  ixgbe base codes: Refine struct for physical information
  ixgbe base codes: Clear Tx pending
  ixgbe base codes: Use IOMEM
  ixgbe base codes: Update macros
  ixgbe base codes: New phy ID
  ixgbe base codes: Get bus info
  ixgbe base codes: Restructure host interface command
  ixgbe base codes: Fix mac type issue
  ixgbe base codes: API for setup internal phy
  ixgbe base codes: API for set phy power
  ixgbe base codes: API for read i2c combined
  ixgbe base codes: API for write i2c combined
  ixgbe base codes: Support 5G link speed
  ixgbe base codes: Refine branch statement
  ixgbe base codes: SFP probe
  ixgbe base codes: Set LAN ID
  ixgbe base codes: Calculate checksum
  ixgbe base codes: Command for flow director
  ixgbe base codes: Auto-negotiation
  ixgbe base codes: Bit-bang mode
  ixgbe base codes: Setup kx4 phy
  ixgbe base codes: Read/write iosf sb stat
  ixgbe base codes: New device id
  ixgbe base codes: Update readme
  eal: Add 2 device ids for ixgbe

 lib/librte_eal/common/include/rte_pci_dev_ids.h |   6 +-
 lib/librte_pmd_ixgbe/ixgbe/README   |   2 +-
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_82598.c|  55 ++-
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_82598.h|   1 -
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_82599.c| 237 +-
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_82599.h|   1 -
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.c  |  61 ++-
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_api.h  |   5 +-
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.c   | 189 +---
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.h   |   5 +-
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_dcb.c  |   1 -
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_dcb.h  |   2 -
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_dcb_82598.c|   1 -
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_dcb_82598.h|   1 -
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_dcb_82599.c|   3 +-
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_dcb_82599.h|   1 -
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_osdep.h|   4 +-
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.c  | 220 +++--
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_phy.h  |   7 +-
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_type.h | 131 +-
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_vf.c   |   1 -
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_vf.h   |   5 -
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_x540.c |  82 ++--
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_x540.h |   1 -
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.c | 582 ++--
 lib/librte_pmd_ixgbe/ixgbe/ixgbe_x550.h |   9 +-
 26 files changed, 1158 insertions(+), 455 deletions(-)

-- 
1.8.4.2



[dpdk-dev] [PATCH 3/3] examples: example showing use of callbacks.

2015-02-12 Thread John McNamara
From: Richardson, Bruce 

Rough example showing how callbacks can be used to insert a timestamp
into each packet on RX. Then on TX the timestamp is used to calculate
the packet latency in cycles through the app.

Signed-off-by: Bruce Richardson 
---
 examples/rxtx_callbacks/Makefile   |   57 +
 examples/rxtx_callbacks/basicfwd.c |  222 
 examples/rxtx_callbacks/basicfwd.h |   46 
 3 files changed, 325 insertions(+), 0 deletions(-)
 create mode 100644 examples/rxtx_callbacks/Makefile
 create mode 100644 examples/rxtx_callbacks/basicfwd.c
 create mode 100644 examples/rxtx_callbacks/basicfwd.h

diff --git a/examples/rxtx_callbacks/Makefile b/examples/rxtx_callbacks/Makefile
new file mode 100644
index 000..4a5d99f
--- /dev/null
+++ b/examples/rxtx_callbacks/Makefile
@@ -0,0 +1,57 @@
+#   BSD LICENSE
+#
+#   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+#   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 Intel 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.
+
+ifeq ($(RTE_SDK),)
+$(error "Please define RTE_SDK environment variable")
+endif
+
+# Default target, can be overridden by command line or environment
+RTE_TARGET ?= x86_64-native-linuxapp-gcc
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+# binary name
+APP = basicfwd
+
+# all source are stored in SRCS-y
+SRCS-y := basicfwd.c
+
+CFLAGS += $(WERROR_FLAGS)
+
+# workaround for a gcc bug with noreturn attribute
+# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603
+ifeq ($(CONFIG_RTE_TOOLCHAIN_GCC),y)
+CFLAGS_main.o += -Wno-return-type
+endif
+
+EXTRA_CFLAGS += -O3 -g -Wfatal-errors
+
+include $(RTE_SDK)/mk/rte.extapp.mk
diff --git a/examples/rxtx_callbacks/basicfwd.c 
b/examples/rxtx_callbacks/basicfwd.c
new file mode 100644
index 000..0209bf4
--- /dev/null
+++ b/examples/rxtx_callbacks/basicfwd.c
@@ -0,0 +1,222 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+ *   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 Intel 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) 

[dpdk-dev] [PATCH 2/3] ethdev: Add in data rxtx callback support

2015-02-12 Thread John McNamara
From: Richardson, Bruce 

Add in support for inline processing of packets inside the RX or
TX call. For an RX callback, what happens is that we get a set of
packets from the NIC and then pass them to a callback function, if
configured, to allow additional processing to be done on them, e.g.
filling in more mbuf fields, before passing back to the application.
On TX, the packets are similarly post-processed before being handed
to the NIC for transmission.

Signed-off-by: Bruce Richardson 
---
 lib/librte_ether/rte_ethdev.c |  165 +-
 lib/librte_ether/rte_ethdev.h |  175 -
 2 files changed, 334 insertions(+), 6 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index e4b3315..944737e 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -337,6 +337,15 @@ rte_eth_dev_rx_queue_config(struct rte_eth_dev *dev, 
uint16_t nb_queues)
dev->data->nb_rx_queues = 0;
return -(ENOMEM);
}
+   dev->rx_cbs = rte_zmalloc("ethdev->rx_cbs",
+   sizeof(*dev->rx_cbs) * nb_queues,
+   RTE_CACHE_LINE_SIZE);
+   if (dev->rx_cbs == NULL) {
+   rte_free(dev->data->rx_queues);
+   dev->data->rx_queues = NULL;
+   dev->data->nb_rx_queues = 0;
+   return -(ENOMEM);
+   }
} else { /* re-configure */
FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_release, -ENOTSUP);

@@ -348,10 +357,18 @@ rte_eth_dev_rx_queue_config(struct rte_eth_dev *dev, 
uint16_t nb_queues)
RTE_CACHE_LINE_SIZE);
if (rxq == NULL)
return -(ENOMEM);
+   dev->rx_cbs = rte_realloc(dev->rx_cbs, sizeof(*dev->rx_cbs) *
+   nb_queues, RTE_CACHE_LINE_SIZE);
+   if (dev->rx_cbs == NULL)
+   return -(ENOMEM);

-   if (nb_queues > old_nb_queues)
+   if (nb_queues > old_nb_queues) {
+   uint16_t new_qs = nb_queues - old_nb_queues;
memset(rxq + old_nb_queues, 0,
-   sizeof(rxq[0]) * (nb_queues - old_nb_queues));
+   sizeof(rxq[0]) * new_qs);
+   memset(dev->rx_cbs + old_nb_queues, 0,
+   sizeof(dev->rx_cbs[0]) * new_qs);
+   }

dev->data->rx_queues = rxq;

@@ -479,6 +496,15 @@ rte_eth_dev_tx_queue_config(struct rte_eth_dev *dev, 
uint16_t nb_queues)
dev->data->nb_tx_queues = 0;
return -(ENOMEM);
}
+   dev->tx_cbs = rte_zmalloc("ethdev->tx_cbs",
+   sizeof(*dev->tx_cbs) * nb_queues,
+   RTE_CACHE_LINE_SIZE);
+   if (dev->tx_cbs == NULL) {
+   rte_free(dev->data->tx_queues);
+   dev->data->tx_queues = NULL;
+   dev->data->nb_tx_queues = 0;
+   return -(ENOMEM);
+   }
} else { /* re-configure */
FUNC_PTR_OR_ERR_RET(*dev->dev_ops->tx_queue_release, -ENOTSUP);

@@ -490,10 +516,19 @@ rte_eth_dev_tx_queue_config(struct rte_eth_dev *dev, 
uint16_t nb_queues)
RTE_CACHE_LINE_SIZE);
if (txq == NULL)
return -(ENOMEM);
+   dev->tx_cbs = rte_realloc(dev->tx_cbs, sizeof(*dev->tx_cbs) *
+   nb_queues, RTE_CACHE_LINE_SIZE);
+   if (dev->tx_cbs == NULL)
+   return -(ENOMEM);
+

-   if (nb_queues > old_nb_queues)
+   if (nb_queues > old_nb_queues) {
+   uint16_t new_qs = nb_queues - old_nb_queues;
memset(txq + old_nb_queues, 0,
-   sizeof(txq[0]) * (nb_queues - old_nb_queues));
+   sizeof(txq[0]) * new_qs);
+   memset(dev->tx_cbs + old_nb_queues, 0,
+   sizeof(dev->tx_cbs[0]) * new_qs);
+   }

dev->data->tx_queues = txq;

@@ -3253,3 +3288,125 @@ rte_eth_dev_filter_ctrl(uint8_t port_id, enum 
rte_filter_type filter_type,
FUNC_PTR_OR_ERR_RET(*dev->dev_ops->filter_ctrl, -ENOTSUP);
return (*dev->dev_ops->filter_ctrl)(dev, filter_type, filter_op, arg);
 }
+
+void *
+rte_eth_add_rx_callback(uint8_t port_id, uint16_t queue_id,
+   rte_rxtx_callback_fn fn, void *user_param)
+{
+   /* check input parameters */
+   if (port_id >= nb_ports || fn == NULL ||
+   queue_id >= 

[dpdk-dev] [PATCH 1/3] ethdev: rename callbacks field to intr_cbs

2015-02-12 Thread John McNamara
From: Richardson, Bruce 

The callbacks member of the rte_eth_dev structure has been renamed
to intr_cbs to make it clear that it refers to callbacks from NIC
interrupts. This then allows us to add other types of callbacks to
the structure without ambiguity.

Signed-off-by: Bruce Richardson 
---
 app/test/virtual_pmd.c |2 +-
 lib/librte_ether/rte_ethdev.c  |   12 ++--
 lib/librte_ether/rte_ethdev.h  |2 +-
 lib/librte_pmd_bond/rte_eth_bond_api.c |2 +-
 4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/app/test/virtual_pmd.c b/app/test/virtual_pmd.c
index 9fac95d..ec2474f 100644
--- a/app/test/virtual_pmd.c
+++ b/app/test/virtual_pmd.c
@@ -576,7 +576,7 @@ virtual_ethdev_create(const char *name, struct ether_addr 
*mac_addr,
eth_dev->data->nb_rx_queues = (uint16_t)1;
eth_dev->data->nb_tx_queues = (uint16_t)1;

-   TAILQ_INIT(&(eth_dev->callbacks));
+   TAILQ_INIT(&(eth_dev->intr_cbs));

eth_dev->data->dev_link.link_status = 0;
eth_dev->data->dev_link.link_speed = ETH_LINK_SPEED_1;
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index ea3a1fb..e4b3315 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -265,7 +265,7 @@ rte_eth_dev_init(struct rte_pci_driver *pci_drv,
eth_dev->data->rx_mbuf_alloc_failed = 0;

/* init user callbacks */
-   TAILQ_INIT(&(eth_dev->callbacks));
+   TAILQ_INIT(&(eth_dev->intr_cbs));

/*
 * Set the default MTU.
@@ -2738,7 +2738,7 @@ rte_eth_dev_callback_register(uint8_t port_id,
dev = _eth_devices[port_id];
rte_spinlock_lock(_eth_dev_cb_lock);

-   TAILQ_FOREACH(user_cb, &(dev->callbacks), next) {
+   TAILQ_FOREACH(user_cb, &(dev->intr_cbs), next) {
if (user_cb->cb_fn == cb_fn &&
user_cb->cb_arg == cb_arg &&
user_cb->event == event) {
@@ -2752,7 +2752,7 @@ rte_eth_dev_callback_register(uint8_t port_id,
user_cb->cb_fn = cb_fn;
user_cb->cb_arg = cb_arg;
user_cb->event = event;
-   TAILQ_INSERT_TAIL(&(dev->callbacks), user_cb, next);
+   TAILQ_INSERT_TAIL(&(dev->intr_cbs), user_cb, next);
}

rte_spinlock_unlock(_eth_dev_cb_lock);
@@ -2779,7 +2779,7 @@ rte_eth_dev_callback_unregister(uint8_t port_id,
rte_spinlock_lock(_eth_dev_cb_lock);

ret = 0;
-   for (cb = TAILQ_FIRST(>callbacks); cb != NULL; cb = next) {
+   for (cb = TAILQ_FIRST(>intr_cbs); cb != NULL; cb = next) {

next = TAILQ_NEXT(cb, next);

@@ -2793,7 +2793,7 @@ rte_eth_dev_callback_unregister(uint8_t port_id,
 * then remove it.
 */
if (cb->active == 0) {
-   TAILQ_REMOVE(&(dev->callbacks), cb, next);
+   TAILQ_REMOVE(&(dev->intr_cbs), cb, next);
rte_free(cb);
} else {
ret = -EAGAIN;
@@ -2812,7 +2812,7 @@ _rte_eth_dev_callback_process(struct rte_eth_dev *dev,
struct rte_eth_dev_callback dev_cb;

rte_spinlock_lock(_eth_dev_cb_lock);
-   TAILQ_FOREACH(cb_lst, &(dev->callbacks), next) {
+   TAILQ_FOREACH(cb_lst, &(dev->intr_cbs), next) {
if (cb_lst->cb_fn == NULL || cb_lst->event != event)
continue;
dev_cb = *cb_lst;
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 1200c1c..9c67488 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1538,7 +1538,7 @@ struct rte_eth_dev {
const struct eth_driver *driver;/**< Driver for this device */
struct eth_dev_ops *dev_ops;/**< Functions exported by PMD */
struct rte_pci_device *pci_dev; /**< PCI info. supplied by probing */
-   struct rte_eth_dev_cb_list callbacks; /**< User application callbacks */
+   struct rte_eth_dev_cb_list intr_cbs; /**< User application callbacks on 
interrupt*/
 };

 struct rte_eth_dev_sriov {
diff --git a/lib/librte_pmd_bond/rte_eth_bond_api.c 
b/lib/librte_pmd_bond/rte_eth_bond_api.c
index 4ab3267..4a66609 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_api.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_api.c
@@ -251,7 +251,7 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t 
socket_id)
eth_dev->data->nb_rx_queues = (uint16_t)1;
eth_dev->data->nb_tx_queues = (uint16_t)1;

-   TAILQ_INIT(&(eth_dev->callbacks));
+   TAILQ_INIT(&(eth_dev->intr_cbs));

eth_dev->data->dev_link.link_status = 0;

-- 
1.7.4.1



[dpdk-dev] [PATCH 0/3] DPDK ethdev callback support

2015-02-12 Thread John McNamara
This patchset is for a small addition to the ethdev library, to
add in support for callbacks at the RX and TX stages. This allows
packet processing to be done on packets before they get returned
to applications using rte_eth_rx_burst call.

See the RFC cover letter for the use cases:

http://dpdk.org/ml/archives/dev/2014-December/010491.html

For this version we spent some time investigating Stephen Hemminger's
suggestion of using the userspace RCU (read-copy-update) library for
SMP safety:

   http://urcu.so/

The default liburcu (which defaulted to liburcu-mb) requires the least
interaction from the end user but showed a 25% drop in packet throughput
in the callback sample app.

The liburcu-qsbr (quiescent state) variant showed a 1% drop in packet
throughput in the callback sample app. However it requires registered
RCU threads in the program to periodically announce quiescent states.
This makes it more difficult to implement for end user applications.

For this release we will document that callbacks should be added/removed
on stopped ports.

Version 1 changes:
* Added callback removal functions.
* Minor fixes.


Richardson, Bruce (3):
  ethdev: rename callbacks field to intr_cbs
  ethdev: Add in data rxtx callback support
  examples: example showing use of callbacks.

 app/test/virtual_pmd.c |2 +-
 examples/rxtx_callbacks/Makefile   |   57 
 examples/rxtx_callbacks/basicfwd.c |  222 
 examples/rxtx_callbacks/basicfwd.h |   46 +++
 lib/librte_ether/rte_ethdev.c  |  177 --
 lib/librte_ether/rte_ethdev.h  |  175 +-
 lib/librte_pmd_bond/rte_eth_bond_api.c |2 +-
 7 files changed, 667 insertions(+), 14 deletions(-)
 create mode 100644 examples/rxtx_callbacks/Makefile
 create mode 100644 examples/rxtx_callbacks/basicfwd.c
 create mode 100644 examples/rxtx_callbacks/basicfwd.h

-- 
1.7.4.1



[dpdk-dev] [PATCH] i40e: fix the issue reported by klocwork

2015-02-12 Thread Jingjing Wu
Klocwork reports array 'src_offset' may use index 16.
In function i40e_srcoff_to_flx_pit, index j + 1 can reach 
I40E_FDIR_MAX_FLEX_LEN.
This patch fixes this issue to avoid array bound.

Signed-off-by: Jingjing Wu 
---
 lib/librte_pmd_i40e/i40e_fdir.c | 35 +--
 1 file changed, 17 insertions(+), 18 deletions(-)

diff --git a/lib/librte_pmd_i40e/i40e_fdir.c b/lib/librte_pmd_i40e/i40e_fdir.c
index 68511c8..bc36d8e 100644
--- a/lib/librte_pmd_i40e/i40e_fdir.c
+++ b/lib/librte_pmd_i40e/i40e_fdir.c
@@ -402,28 +402,27 @@ i40e_srcoff_to_flx_pit(const uint16_t *src_offset,

while (j < I40E_FDIR_MAX_FLEX_LEN) {
size = 1;
-   for (; j < I40E_FDIR_MAX_FLEX_LEN; j++) {
+   for (; j < I40E_FDIR_MAX_FLEX_LEN - 1; j++) {
if (src_offset[j + 1] == src_offset[j] + 1)
size++;
-   else {
-   src_tmp = src_offset[j] + 1 - size;
-   /* the flex_pit need to be sort by scr_offset */
-   for (i = 0; i < num; i++) {
-   if (src_tmp < flex_pit[i].src_offset)
-   break;
-   }
-   /* if insert required, move backward */
-   for (k = num; k > i; k--)
-   flex_pit[k] = flex_pit[k - 1];
-   /* insert */
-   flex_pit[i].dst_offset = j + 1 - size;
-   flex_pit[i].src_offset = src_tmp;
-   flex_pit[i].size = size;
-   j++;
-   num++;
+   else
+   break;
+   }
+   src_tmp = src_offset[j] + 1 - size;
+   /* the flex_pit need to be sort by src_offset */
+   for (i = 0; i < num; i++) {
+   if (src_tmp < flex_pit[i].src_offset)
break;
-   }
}
+   /* if insert required, move backward */
+   for (k = num; k > i; k--)
+   flex_pit[k] = flex_pit[k - 1];
+   /* insert */
+   flex_pit[i].dst_offset = j + 1 - size;
+   flex_pit[i].src_offset = src_tmp;
+   flex_pit[i].size = size;
+   j++;
+   num++;
}
return num;
 }
-- 
1.9.3



[dpdk-dev] Packet drops during non-exhaustive flood with OVS and 1.8.0

2015-02-12 Thread Andrey Korolyov
On Thu, Feb 12, 2015 at 6:05 PM, Traynor, Kevin  
wrote:
>> -Original Message-
>> From: Andrey Korolyov [mailto:andrey at xdel.ru]
>> Sent: Tuesday, February 3, 2015 5:21 PM
>> To: Traynor, Kevin
>> Cc: dev at dpdk.org; discuss at openvswitch.org
>> Subject: Re: Packet drops during non-exhaustive flood with OVS and 1.8.0
>>
>> > These patches are to enable DPDK 1.8 only. What 'bulk processing' are you 
>> > referring to?
>> > By default there is a batch size of 192 in netdev-dpdk for rx from the NIC 
>> > - the linked
>> > patch doesn't change this, just the DPDK version.
>>
>> Sorry, I referred the wrong part there: bulk transmission, which is
>> clearly not involved in my case. The idea was that the conditionally
>> enabling prefetch for rx queues (BULK_ALLOC) may help somehow, but
>> it`s probably will mask issue instead of solving it directly. By my
>> understanding, strict drop rule should have a zero impact on a main
>> ovs thread (and this is true) and work just fine with a line rate
>> (this is not).
>
> I've set a similar drop rule and I'm seeing the first packet drops occurring
> at 13.9 mpps for 64 byte pkts. I'm not sure if there is a config that can be
> changed or if it just the cost of the emc/lookups
>

Do you mind to compare this case with forward to the dummy port
(ifconfig dummy0; ovs-vsctl add-port br0 dummy0; ip link set dev
dummy0 up; flush rule table; create a single forward rule; start an
attack)? As I mentioned there are no signs of syscall congestion for a
drop or dpdk-dpdk forward case.


[dpdk-dev] [PATCH 1/7] vmxnet3: add support for VLAN filtering

2015-02-12 Thread Yong Wang
On 12/16/14, 9:13 PM, "Stephen Hemminger" 
wrote:

>From: Stephen Hemminger 
>
>VMXNET3 supports configuring filter table in host.
>
>Signed-off-by: Stephen Hemminger 
>---
> lib/librte_pmd_vmxnet3/vmxnet3_ethdev.c | 107
>+---
> lib/librte_pmd_vmxnet3/vmxnet3_ethdev.h |   2 +-
> lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c   |  25 
> 3 files changed, 99 insertions(+), 35 deletions(-)
>
>diff --git a/lib/librte_pmd_vmxnet3/vmxnet3_ethdev.c
>b/lib/librte_pmd_vmxnet3/vmxnet3_ethdev.c
>index ef0af16..30d0659 100644
>--- a/lib/librte_pmd_vmxnet3/vmxnet3_ethdev.c
>+++ b/lib/librte_pmd_vmxnet3/vmxnet3_ethdev.c
>@@ -87,6 +87,12 @@ static void vmxnet3_dev_stats_get(struct rte_eth_dev
>*dev,
>   struct rte_eth_stats *stats);
> static void vmxnet3_dev_info_get(struct rte_eth_dev *dev,
>   struct rte_eth_dev_info *dev_info);
>+static int vmxnet3_dev_vlan_filter_set(struct rte_eth_dev *dev,
>+ uint16_t vid, int on);
>+static void vmxnet3_dev_vlan_offload_set(struct rte_eth_dev *dev, int
>mask);
>+static void vmxnet3_dev_vlan_offload_set_clear(struct rte_eth_dev *dev,
>+  int mask, int clear);
>+
> #if PROCESS_SYS_EVENTS == 1
> static void vmxnet3_process_events(struct vmxnet3_hw *);
> #endif
>@@ -113,6 +119,8 @@ static struct eth_dev_ops vmxnet3_eth_dev_ops = {
>   .link_update  = vmxnet3_dev_link_update,
>   .stats_get= vmxnet3_dev_stats_get,
>   .dev_infos_get= vmxnet3_dev_info_get,
>+  .vlan_filter_set  = vmxnet3_dev_vlan_filter_set,
>+  .vlan_offload_set = vmxnet3_dev_vlan_offload_set,
>   .rx_queue_setup   = vmxnet3_dev_rx_queue_setup,
>   .rx_queue_release = vmxnet3_dev_rx_queue_release,
>   .tx_queue_setup   = vmxnet3_dev_tx_queue_setup,
>@@ -371,7 +379,7 @@ vmxnet3_setup_driver_shared(struct rte_eth_dev *dev)
>   Vmxnet3_DSDevRead *devRead = >devRead;
>   uint32_t *mac_ptr;
>   uint32_t val, i;
>-  int ret;
>+  int ret, mask;
> 
>   shared->magic = VMXNET3_REV1_MAGIC;
>   devRead->misc.driverInfo.version = VMXNET3_DRIVER_VERSION_NUM;
>@@ -442,9 +450,6 @@ vmxnet3_setup_driver_shared(struct rte_eth_dev *dev)
>   if (dev->data->dev_conf.rxmode.hw_ip_checksum)
>   devRead->misc.uptFeatures |= VMXNET3_F_RXCSUM;
> 
>-  if (dev->data->dev_conf.rxmode.hw_vlan_strip)
>-  devRead->misc.uptFeatures |= VMXNET3_F_RXVLAN;
>-
>   if (port_conf.rxmode.mq_mode == ETH_MQ_RX_RSS) {
>   ret = vmxnet3_rss_configure(dev);
>   if (ret != VMXNET3_SUCCESS)
>@@ -456,11 +461,14 @@ vmxnet3_setup_driver_shared(struct rte_eth_dev *dev)
>   devRead->rssConfDesc.confPA  = hw->rss_confPA;
>   }
> 
>-  if (dev->data->dev_conf.rxmode.hw_vlan_filter) {
>-  ret = vmxnet3_vlan_configure(dev);
>-  if (ret != VMXNET3_SUCCESS)
>-  return ret;
>-  }
>+  mask = 0;
>+  if (dev->data->dev_conf.rxmode.hw_vlan_strip)
>+  mask |= ETH_VLAN_STRIP_MASK;
>+
>+  if (dev->data->dev_conf.rxmode.hw_vlan_filter)
>+  mask |= ETH_VLAN_FILTER_MASK;
>+
>+  vmxnet3_dev_vlan_offload_set_clear(dev, mask, 1);
> 
>   PMD_INIT_LOG(DEBUG,
>"Writing MAC Address : %02x:%02x:%02x:%02x:%02x:%02x",
>@@ -690,13 +698,23 @@ vmxnet3_dev_set_rxmode(struct vmxnet3_hw *hw,
>uint32_t feature, int set) {
>   VMXNET3_WRITE_BAR1_REG(hw, VMXNET3_REG_CMD, VMXNET3_CMD_UPDATE_RX_MODE);
> }
> 
>+static void
>+vmxnet3_dev_update_filters(struct vmxnet3_hw *hw)
>+{
>+  VMXNET3_WRITE_BAR1_REG(hw, VMXNET3_REG_CMD,
>+ VMXNET3_CMD_UPDATE_VLAN_FILTERS);
>+}

This function is not really necessary given what it does.  If you prefer
to keep it, please rename it to vmxnet3_dev_update_vlan_filters to be more
precise.

>+
> /* Promiscuous supported only if Vmxnet3_DriverShared is initialized in
>adapter */
> static void
> vmxnet3_dev_promiscuous_enable(struct rte_eth_dev *dev)
> {
>   struct vmxnet3_hw *hw = dev->data->dev_private;
>+  uint32_t *vf_table = hw->shared->devRead.rxFilterConf.vfTable;
> 
>+  memset(vf_table, 0, VMXNET3_VFT_SIZE * sizeof(*vf_table));
>   vmxnet3_dev_set_rxmode(hw, VMXNET3_RXM_PROMISC, 1);
>+  vmxnet3_dev_update_filters(hw);
> }
> 
> /* Promiscuous supported only if Vmxnet3_DriverShared is initialized in
>adapter */
>@@ -704,8 +722,11 @@ static void
> vmxnet3_dev_promiscuous_disable(struct rte_eth_dev *dev)
> {
>   struct vmxnet3_hw *hw = dev->data->dev_private;
>+  uint32_t *vf_table = hw->shared->devRead.rxFilterConf.vfTable;
> 
>+  memset(vf_table, 0, VMXNET3_VFT_SIZE * sizeof(*vf_table));

Rather than clearing all vlan filters, we should restore the saved filters
in shadow_vfta before promiscuous mode is enabled.  This is also needed
when the device is 

[dpdk-dev] [PATCH v2 09/11] lib/librte_vhost: vhost user support

2015-02-12 Thread Linhaifeng


On 2015/2/12 17:28, Xie, Huawei wrote:
> On 2/12/2015 4:28 PM, Linhaifeng wrote:
>>
>> On 2015/2/12 13:07, Huawei Xie wrote:
>>> +
>>> +   /* This is ugly */
>>> +   mapped_size = memory.regions[idx].memory_size +
>>> +   memory.regions[idx].mmap_offset;
>>> +   mapped_address = (uint64_t)(uintptr_t)mmap(NULL,
>>> +   mapped_size,
>>> +   PROT_READ | PROT_WRITE, MAP_SHARED,
>>> +   pmsg->fds[idx],
>>> +   0);
>> Just another ugly way:
>> We can use the size of file to mmap then unmmap is not need align to the 
>> size of page.
>>
> Yes, this is like how cuses handle mmap.
> We will add this into the to-do list, combine all the regions the first,
> check if they belong to the same file, and then map each file once.
> Seems there is no elegant way.
> 
> There is another to do for mmap. If there are multiple virtio devices,
> the memory are mapped for each virtio device. Actually we only need once.
> 

Great minds think alike.

The graceful way is qemu send a message to us to mmap whit which file and size 
then
we not need to mmap for each virtio device.

> 
> 
> 

-- 
Regards,
Haifeng



[dpdk-dev] [PATCH v3 2/2] eal: add help option

2015-02-12 Thread Thomas Monjalon
Help is printed with -h or --help.

Help is also printed for an unknown option.
This was broken since the rework of options.

Fixes: 489a9d6c9f77 ("merge bsd and linux common options parsing")

Signed-off-by: Thomas Monjalon 
Acked-by: David Marchand 
---
 lib/librte_eal/bsdapp/eal/eal.c| 7 ++-
 lib/librte_eal/common/eal_common_options.c | 3 +++
 lib/librte_eal/common/eal_options.h| 2 ++
 lib/librte_eal/linuxapp/eal/eal.c  | 8 +++-
 4 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c
index 69f3c03..ca2f445 100644
--- a/lib/librte_eal/bsdapp/eal/eal.c
+++ b/lib/librte_eal/bsdapp/eal/eal.c
@@ -326,8 +326,10 @@ eal_parse_args(int argc, char **argv)
int ret;

/* getopt is not happy, stop right now */
-   if (opt == '?')
+   if (opt == '?') {
+   eal_usage(prgname);
return -1;
+   }

ret = eal_parse_common_option(opt, optarg, _config);
/* common parser is not happy */
@@ -340,6 +342,9 @@ eal_parse_args(int argc, char **argv)
continue;

switch (opt) {
+   case 'h':
+   eal_usage(prgname);
+   exit(EXIT_SUCCESS);
default:
if (opt < OPT_LONG_MIN_NUM && isprint(opt)) {
RTE_LOG(ERR, EAL, "Option %c is not supported "
diff --git a/lib/librte_eal/common/eal_common_options.c 
b/lib/librte_eal/common/eal_common_options.c
index 3dda237..4314e4e 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -57,6 +57,7 @@ eal_short_options[] =
"b:" /* pci-blacklist */
"c:" /* coremask */
"d:" /* driver */
+   "h"  /* help */
"l:" /* corelist */
"m:" /* memory size */
"n:" /* memory channels */
@@ -70,6 +71,7 @@ eal_long_options[] = {
{OPT_BASE_VIRTADDR, 1, NULL, OPT_BASE_VIRTADDR_NUM},
{OPT_CREATE_UIO_DEV,1, NULL, OPT_CREATE_UIO_DEV_NUM   },
{OPT_FILE_PREFIX,   1, NULL, OPT_FILE_PREFIX_NUM  },
+   {OPT_HELP,  0, NULL, OPT_HELP_NUM },
{OPT_HUGE_DIR,  1, NULL, OPT_HUGE_DIR_NUM },
{OPT_LOG_LEVEL, 1, NULL, OPT_LOG_LEVEL_NUM},
{OPT_MASTER_LCORE,  1, NULL, OPT_MASTER_LCORE_NUM },
@@ -605,6 +607,7 @@ eal_common_usage(void)
   "  --"OPT_SYSLOG"Set syslog facility\n"
   "  --"OPT_LOG_LEVEL" Set default log level\n"
   "  -v  Display version information on startup\n"
+  "  -h, --help  This help\n"
   "\nEAL options for DEBUG use only:\n"
   "  --"OPT_NO_HUGE"   Use malloc instead of hugetlbfs\n"
   "  --"OPT_NO_PCI"Disable PCI\n"
diff --git a/lib/librte_eal/common/eal_options.h 
b/lib/librte_eal/common/eal_options.h
index fe1c85d..d199a00 100644
--- a/lib/librte_eal/common/eal_options.h
+++ b/lib/librte_eal/common/eal_options.h
@@ -35,6 +35,8 @@

 enum {
/* long options mapped to a short option */
+#define OPT_HELP  "help"
+   OPT_HELP_NUM= 'h',
 #define OPT_PCI_BLACKLIST "pci-blacklist"
OPT_PCI_BLACKLIST_NUM   = 'b',
 #define OPT_PCI_WHITELIST "pci-whitelist"
diff --git a/lib/librte_eal/linuxapp/eal/eal.c 
b/lib/librte_eal/linuxapp/eal/eal.c
index e3955e7..d8c0628 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -520,8 +520,10 @@ eal_parse_args(int argc, char **argv)
int ret;

/* getopt is not happy, stop right now */
-   if (opt == '?')
+   if (opt == '?') {
+   eal_usage(prgname);
return -1;
+   }

ret = eal_parse_common_option(opt, optarg, _config);
/* common parser is not happy */
@@ -534,6 +536,10 @@ eal_parse_args(int argc, char **argv)
continue;

switch (opt) {
+   case 'h':
+   eal_usage(prgname);
+   exit(EXIT_SUCCESS);
+
/* force loading of external driver */
case 'd':
solib = malloc(sizeof(*solib));
-- 
2.2.2



[dpdk-dev] [PATCH v3 1/2] eal: sort and align options lists

2015-02-12 Thread Thomas Monjalon
Options listing in usage help was a mess.
The main usage line is fixed and shorter.
The options in usage output are logically sorted (cpu/mem/dev/proc),
aligned and lightly reworded.
The options in declarations are alphabetically sorted.
Code in swith statement is not moved.

Signed-off-by: Thomas Monjalon 
---
changes in v3:
- reword arguments in usage 
 
changes in v2:
- sort and align options enum in .h
---
 lib/librte_eal/common/eal_common_options.c | 112 ++---
 lib/librte_eal/common/eal_options.h|  62 
 lib/librte_eal/linuxapp/eal/eal.c  |  19 +++--
 3 files changed, 95 insertions(+), 98 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_options.c 
b/lib/librte_eal/common/eal_common_options.c
index 67e02dc..3dda237 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -55,37 +55,38 @@
 const char
 eal_short_options[] =
"b:" /* pci-blacklist */
-   "w:" /* pci-whitelist */
"c:" /* coremask */
-   "d:"
+   "d:" /* driver */
"l:" /* corelist */
-   "m:"
-   "n:"
-   "r:"
-   "v";
+   "m:" /* memory size */
+   "n:" /* memory channels */
+   "r:" /* memory ranks */
+   "v"  /* version */
+   "w:" /* pci-whitelist */
+   ;

 const struct option
 eal_long_options[] = {
-   {OPT_HUGE_DIR, 1, 0, OPT_HUGE_DIR_NUM},
-   {OPT_MASTER_LCORE, 1, 0, OPT_MASTER_LCORE_NUM},
-   {OPT_PROC_TYPE, 1, 0, OPT_PROC_TYPE_NUM},
-   {OPT_NO_SHCONF, 0, 0, OPT_NO_SHCONF_NUM},
-   {OPT_NO_HPET, 0, 0, OPT_NO_HPET_NUM},
-   {OPT_VMWARE_TSC_MAP, 0, 0, OPT_VMWARE_TSC_MAP_NUM},
-   {OPT_NO_PCI, 0, 0, OPT_NO_PCI_NUM},
-   {OPT_NO_HUGE, 0, 0, OPT_NO_HUGE_NUM},
-   {OPT_FILE_PREFIX, 1, 0, OPT_FILE_PREFIX_NUM},
-   {OPT_SOCKET_MEM, 1, 0, OPT_SOCKET_MEM_NUM},
-   {OPT_PCI_WHITELIST, 1, 0, OPT_PCI_WHITELIST_NUM},
-   {OPT_PCI_BLACKLIST, 1, 0, OPT_PCI_BLACKLIST_NUM},
-   {OPT_VDEV, 1, 0, OPT_VDEV_NUM},
-   {OPT_SYSLOG, 1, NULL, OPT_SYSLOG_NUM},
-   {OPT_LOG_LEVEL, 1, NULL, OPT_LOG_LEVEL_NUM},
-   {OPT_BASE_VIRTADDR, 1, 0, OPT_BASE_VIRTADDR_NUM},
-   {OPT_XEN_DOM0, 0, 0, OPT_XEN_DOM0_NUM},
-   {OPT_CREATE_UIO_DEV, 1, NULL, OPT_CREATE_UIO_DEV_NUM},
-   {OPT_VFIO_INTR, 1, NULL, OPT_VFIO_INTR_NUM},
-   {0, 0, 0, 0}
+   {OPT_BASE_VIRTADDR, 1, NULL, OPT_BASE_VIRTADDR_NUM},
+   {OPT_CREATE_UIO_DEV,1, NULL, OPT_CREATE_UIO_DEV_NUM   },
+   {OPT_FILE_PREFIX,   1, NULL, OPT_FILE_PREFIX_NUM  },
+   {OPT_HUGE_DIR,  1, NULL, OPT_HUGE_DIR_NUM },
+   {OPT_LOG_LEVEL, 1, NULL, OPT_LOG_LEVEL_NUM},
+   {OPT_MASTER_LCORE,  1, NULL, OPT_MASTER_LCORE_NUM },
+   {OPT_NO_HPET,   0, NULL, OPT_NO_HPET_NUM  },
+   {OPT_NO_HUGE,   0, NULL, OPT_NO_HUGE_NUM  },
+   {OPT_NO_PCI,0, NULL, OPT_NO_PCI_NUM   },
+   {OPT_NO_SHCONF, 0, NULL, OPT_NO_SHCONF_NUM},
+   {OPT_PCI_BLACKLIST, 1, NULL, OPT_PCI_BLACKLIST_NUM},
+   {OPT_PCI_WHITELIST, 1, NULL, OPT_PCI_WHITELIST_NUM},
+   {OPT_PROC_TYPE, 1, NULL, OPT_PROC_TYPE_NUM},
+   {OPT_SOCKET_MEM,1, NULL, OPT_SOCKET_MEM_NUM   },
+   {OPT_SYSLOG,1, NULL, OPT_SYSLOG_NUM   },
+   {OPT_VDEV,  1, NULL, OPT_VDEV_NUM },
+   {OPT_VFIO_INTR, 1, NULL, OPT_VFIO_INTR_NUM},
+   {OPT_VMWARE_TSC_MAP,0, NULL, OPT_VMWARE_TSC_MAP_NUM   },
+   {OPT_XEN_DOM0,  0, NULL, OPT_XEN_DOM0_NUM },
+   {0, 0, NULL, 0}
 };

 static int lcores_parsed;
@@ -578,37 +579,36 @@ eal_check_common_options(struct internal_config 
*internal_cfg)
 void
 eal_common_usage(void)
 {
-   printf("-c COREMASK -n NUM [-m NB] [-r NUM] [-b 
]"
-  "[--proc-type primary|secondary|auto]\n\n"
+   printf("-c COREMASK|-l CORELIST -n CHANNELS [options]\n\n"
   "EAL common options:\n"
-  "  -c COREMASK  : A hexadecimal bitmask of cores to run on\n"
-  "  -l CORELIST  : List of cores to run on\n"
-  " The argument format is 
[-c2][,c3[-c4],...]\n"
-  " where c1, c2, etc are core indexes between 0 
and %d\n"
-  "  --"OPT_MASTER_LCORE" ID: Core ID that is used as master\n"
-  "  -n NUM   : Number of memory channels\n"
-  "  -v   : Display version information on startup\n"
-  "  -m MB: memory to allocate (see also 
--"OPT_SOCKET_MEM")\n"
-  "  -r NUM   : force number of memory ranks (don't detect)\n"
-  "  --"OPT_SYSLOG" : set syslog facility\n"
-  "  

[dpdk-dev] [PATCH v3 0/2] help option

2015-02-12 Thread Thomas Monjalon
This is a small reorganization of options.
The main goal is to provide a nice --help option.

changes in v3:
- reword arguments in usage
changes in v2:
- sort also the options enum

Thomas Monjalon (2):
  eal: sort and align options lists
  eal: add help option

 lib/librte_eal/bsdapp/eal/eal.c|   7 +-
 lib/librte_eal/common/eal_common_options.c | 115 +++--
 lib/librte_eal/common/eal_options.h|  64 
 lib/librte_eal/linuxapp/eal/eal.c  |  27 ---
 4 files changed, 113 insertions(+), 100 deletions(-)

-- 
2.2.2



[dpdk-dev] [PATCH v2] eal_pci: Fix max_vfs missing for none igb_uio driver

2015-02-12 Thread Thomas Monjalon
2015-02-11 21:25, Michael Qiu:
> max_vfs will only be created by igb_uio driver, for other
> drivers like vfio or pci_uio_generic, max_vfs will miss.
> 
> But sriov_numvfs is not driver related, just get the vf numbers
> from that field.
> 
> Signed-off-by: Michael Qiu 
[...]
>   snprintf(filename, sizeof(filename), "%s/max_vfs", dirname);
>   if (!access(filename, F_OK) &&
> - eal_parse_sysfs_value(filename, ) == 0) {
> + eal_parse_sysfs_value(filename, ) == 0)
>   dev->max_vfs = (uint16_t)tmp;
> + else {
> + /* for none igb_uio driver, need kernel

I think it's a typo. Do you mean "for non igb_uio driver"?

> +  * version greater than 3.8 */
> + snprintf(filename, sizeof(filename),
> +  "%s/sriov_numvfs", dirname);
> + if (!access(filename, F_OK) &&
> + eal_parse_sysfs_value(filename, ) == 0)
> + dev->max_vfs = (uint16_t)tmp;
>   }
>  
>   /* get numa node */
> 



[dpdk-dev] [PATCH v2] mk: Only default to -Werror when building from git checkout

2015-02-12 Thread Panu Matilainen
Add RTE_DEVEL_BUILD make-variable which can be used to do things
differently when doing development vs building a release,
autodetected from source root .git presence and overridable via
commandline. Use it to only enable -Werror compiler flag when
building a git checkout:

Failing build on warnings is a useful developer tool but its bad
for release tarballs which can and do get built with newer
compilers than what was used/available during development. Compilers
routinely add new warnings so code which built silently with cc X
might no longer do so with X+1. This doesn't make the existing code
any more buggier and failing the build in this case does not help
not help improve code quality of an already released version either.
---
 mk/rte.vars.mk | 4 
 mk/toolchain/clang/rte.vars.mk | 6 +-
 mk/toolchain/gcc/rte.vars.mk   | 6 +-
 mk/toolchain/icc/rte.vars.mk   | 6 +-
 4 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/mk/rte.vars.mk b/mk/rte.vars.mk
index d5b36be..a4ad367 100644
--- a/mk/rte.vars.mk
+++ b/mk/rte.vars.mk
@@ -71,6 +71,10 @@ ifneq ($(BUILDING_RTE_SDK),)
   ifeq ($(RTE_BUILD_COMBINE_LIBS),)
 RTE_BUILD_COMBINE_LIBS := n
   endif
+  # see if we're building from git
+  ifneq ($(wildcard $(RTE_SDK)/.git),)
+RTE_DEVEL_BUILD := y
+  endif
 endif

 RTE_LIBNAME := $(CONFIG_RTE_LIBNAME:"%"=%)
diff --git a/mk/toolchain/clang/rte.vars.mk b/mk/toolchain/clang/rte.vars.mk
index 40cb389..01b1860 100644
--- a/mk/toolchain/clang/rte.vars.mk
+++ b/mk/toolchain/clang/rte.vars.mk
@@ -63,12 +63,16 @@ TOOLCHAIN_ASFLAGS =
 TOOLCHAIN_CFLAGS =
 TOOLCHAIN_LDFLAGS =

-WERROR_FLAGS := -W -Wall -Werror -Wstrict-prototypes -Wmissing-prototypes
+WERROR_FLAGS := -W -Wall -Wstrict-prototypes -Wmissing-prototypes
 WERROR_FLAGS += -Wmissing-declarations -Wold-style-definition -Wpointer-arith
 WERROR_FLAGS += -Wnested-externs -Wcast-qual
 WERROR_FLAGS += -Wformat-nonliteral -Wformat-security
 WERROR_FLAGS += -Wundef -Wwrite-strings

+ifeq ($(RTE_DEVEL_BUILD),y)
+WERROR_FLAGS += -Werror
+endif
+
 # process cpu flags
 include $(RTE_SDK)/mk/toolchain/$(RTE_TOOLCHAIN)/rte.toolchain-compat.mk

diff --git a/mk/toolchain/gcc/rte.vars.mk b/mk/toolchain/gcc/rte.vars.mk
index 88f235c..fc3a642 100644
--- a/mk/toolchain/gcc/rte.vars.mk
+++ b/mk/toolchain/gcc/rte.vars.mk
@@ -71,12 +71,16 @@ ifeq (,$(findstring -O0,$(EXTRA_CFLAGS)))
 endif
 endif

-WERROR_FLAGS := -W -Wall -Werror -Wstrict-prototypes -Wmissing-prototypes
+WERROR_FLAGS := -W -Wall -Wstrict-prototypes -Wmissing-prototypes
 WERROR_FLAGS += -Wmissing-declarations -Wold-style-definition -Wpointer-arith
 WERROR_FLAGS += -Wcast-align -Wnested-externs -Wcast-qual
 WERROR_FLAGS += -Wformat-nonliteral -Wformat-security
 WERROR_FLAGS += -Wundef -Wwrite-strings

+ifeq ($(RTE_DEVEL_BUILD),y)
+WERROR_FLAGS += -Werror
+endif
+
 # process cpu flags
 include $(RTE_SDK)/mk/toolchain/$(RTE_TOOLCHAIN)/rte.toolchain-compat.mk

diff --git a/mk/toolchain/icc/rte.vars.mk b/mk/toolchain/icc/rte.vars.mk
index e39d710..0850719 100644
--- a/mk/toolchain/icc/rte.vars.mk
+++ b/mk/toolchain/icc/rte.vars.mk
@@ -69,9 +69,13 @@ TOOLCHAIN_ASFLAGS =
 #   error #13368: loop was not vectorized with "vector always assert"
 #   error #15527: loop was not vectorized: function call to fprintf cannot be 
vectorize
 #   was declared "deprecated"
-WERROR_FLAGS := -Wall -Werror-all -w2 -diag-disable 271 -diag-warning 1478
+WERROR_FLAGS := -Wall -w2 -diag-disable 271 -diag-warning 1478
 WERROR_FLAGS += -diag-disable 13368 -diag-disable 15527

+ifeq ($(RTE_DEVEL_BUILD),y)
+WERROR_FLAGS += -Werror-all
+endif
+
 # process cpu flags
 include $(RTE_SDK)/mk/toolchain/$(RTE_TOOLCHAIN)/rte.toolchain-compat.mk
 # disable max-inline params boundaries for ICC 15 compiler
-- 
2.1.0



[dpdk-dev] [PATCH v1] afpacket: fix critical issue reported by klocwork

2015-02-12 Thread Cunming Liang
Klocwork report 'req' might be used uninitialized.
In some cases it can 'goto error' when '*internals' not been set.
The result is unexpected checking the value of '*internals'.

Signed-off-by: Cunming Liang 
---
 lib/librte_pmd_af_packet/rte_eth_af_packet.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/librte_pmd_af_packet/rte_eth_af_packet.c 
b/lib/librte_pmd_af_packet/rte_eth_af_packet.c
index 1ffe1cd..185607d 100644
--- a/lib/librte_pmd_af_packet/rte_eth_af_packet.c
+++ b/lib/librte_pmd_af_packet/rte_eth_af_packet.c
@@ -439,13 +439,15 @@ rte_pmd_init_internals(const char *name,
size_t ifnamelen;
unsigned k_idx;
struct sockaddr_ll sockaddr;
-   struct tpacket_req *req;
+   struct tpacket_req *req = NULL;
struct pkt_rx_queue *rx_queue;
struct pkt_tx_queue *tx_queue;
int rc, qsockfd, tpver, discard;
unsigned int i, q, rdsize;
int fanout_arg __rte_unused, bypass __rte_unused;

+   *internals = NULL;
+
for (k_idx = 0; k_idx < kvlist->count; k_idx++) {
pair = >pairs[k_idx];
if (strstr(pair->key, ETH_AF_PACKET_IFACE_ARG) != NULL)
-- 
1.8.1.4



[dpdk-dev] [PATCH v2] mk: fix librte_vhost linking

2015-02-12 Thread Thomas Monjalon
> > librte_vhost is not a plugin but a library, move it to proper section to fix
> > sample app build in shared, non-combined library setup.
> > 
> > Signed-off-by: Panu Matilainen 
> 
> Acked-by: Sergio Gonzalez Monroy 

Applied, thanks


[dpdk-dev] [PATCH] Make -Werror optional

2015-02-12 Thread Panu Matilainen
On 02/12/2015 04:38 PM, Stephen Hemminger wrote:
> On Thu, 12 Feb 2015 13:13:22 +0200
> Panu Matilainen  wrote:
>
>> This adds new CONFIG_RTE_ERROR_ON_WARNING config option to enable
>> fail-on-warning compile behavior, defaulting to off.
>>
>> Failing build on warnings is a useful developer tool but its bad
>> for release tarballs which can and do get built with newer
>> compilers than what was used/available during development. Compilers
>> routinely add new warnings so code which built silently with cc X
>> might no longer do so with X+1. This doesn't make the existing code
>> any more buggier and failing the build in this case does not help
>> not help improve code quality of an already released version either.
>> ---
>>   config/common_bsdapp   | 1 +
>>   config/common_linuxapp | 1 +
>>   mk/toolchain/clang/rte.vars.mk | 5 -
>>   mk/toolchain/gcc/rte.vars.mk   | 5 -
>>   mk/toolchain/icc/rte.vars.mk   | 6 +-
>>   5 files changed, 15 insertions(+), 3 deletions(-)
>>
>> diff --git a/config/common_bsdapp b/config/common_bsdapp
>> index 57bacb8..a5687b3 100644
>> --- a/config/common_bsdapp
>> +++ b/config/common_bsdapp
>> @@ -362,6 +362,7 @@ CONFIG_RTE_KNI_VHOST_DEBUG_TX=n
>>   # Enable warning directives
>>   #
>>   CONFIG_RTE_INSECURE_FUNCTION_WARNING=n
>> +CONFIG_RTE_ERROR_ON_WARNING=n
>>
>>   #
>>   # Compile the test application
>> diff --git a/config/common_linuxapp b/config/common_linuxapp
>> index d428f84..0762f99 100644
>> --- a/config/common_linuxapp
>> +++ b/config/common_linuxapp
>> @@ -383,6 +383,7 @@ CONFIG_RTE_LIBRTE_XEN_DOM0=n
>>   # Enable warning directives
>>   #
>>   CONFIG_RTE_INSECURE_FUNCTION_WARNING=n
>> +CONFIG_RTE_ERROR_ON_WARNING=n
>>
>>   #
>>   # Compile the test application
>> diff --git a/mk/toolchain/clang/rte.vars.mk b/mk/toolchain/clang/rte.vars.mk
>> index 40cb389..12726e7 100644
>> --- a/mk/toolchain/clang/rte.vars.mk
>> +++ b/mk/toolchain/clang/rte.vars.mk
>> @@ -63,11 +63,14 @@ TOOLCHAIN_ASFLAGS =
>>   TOOLCHAIN_CFLAGS =
>>   TOOLCHAIN_LDFLAGS =
>>
>> -WERROR_FLAGS := -W -Wall -Werror -Wstrict-prototypes -Wmissing-prototypes
>> +WERROR_FLAGS := -W -Wall -Wstrict-prototypes -Wmissing-prototypes
>>   WERROR_FLAGS += -Wmissing-declarations -Wold-style-definition 
>> -Wpointer-arith
>>   WERROR_FLAGS += -Wnested-externs -Wcast-qual
>>   WERROR_FLAGS += -Wformat-nonliteral -Wformat-security
>>   WERROR_FLAGS += -Wundef -Wwrite-strings
>> +ifeq ($(CONFIG_RTE_ERROR_ON_WARNING),y)
>> +WERROR_FLAGS += -Werror
>> +endif
>>
>>   # process cpu flags
>>   include $(RTE_SDK)/mk/toolchain/$(RTE_TOOLCHAIN)/rte.toolchain-compat.mk
>> diff --git a/mk/toolchain/gcc/rte.vars.mk b/mk/toolchain/gcc/rte.vars.mk
>> index 88f235c..bbd3c85 100644
>> --- a/mk/toolchain/gcc/rte.vars.mk
>> +++ b/mk/toolchain/gcc/rte.vars.mk
>> @@ -71,11 +71,14 @@ ifeq (,$(findstring -O0,$(EXTRA_CFLAGS)))
>>   endif
>>   endif
>>
>> -WERROR_FLAGS := -W -Wall -Werror -Wstrict-prototypes -Wmissing-prototypes
>> +WERROR_FLAGS := -W -Wall -Wstrict-prototypes -Wmissing-prototypes
>>   WERROR_FLAGS += -Wmissing-declarations -Wold-style-definition 
>> -Wpointer-arith
>>   WERROR_FLAGS += -Wcast-align -Wnested-externs -Wcast-qual
>>   WERROR_FLAGS += -Wformat-nonliteral -Wformat-security
>>   WERROR_FLAGS += -Wundef -Wwrite-strings
>> +ifeq ($(CONFIG_RTE_ERROR_ON_WARNING),y)
>> +WERROR_FLAGS += -Werror
>> +endif
>>
>>   # process cpu flags
>>   include $(RTE_SDK)/mk/toolchain/$(RTE_TOOLCHAIN)/rte.toolchain-compat.mk
>> diff --git a/mk/toolchain/icc/rte.vars.mk b/mk/toolchain/icc/rte.vars.mk
>> index e39d710..652cca8 100644
>> --- a/mk/toolchain/icc/rte.vars.mk
>> +++ b/mk/toolchain/icc/rte.vars.mk
>> @@ -69,8 +69,12 @@ TOOLCHAIN_ASFLAGS =
>>   #   error #13368: loop was not vectorized with "vector always assert"
>>   #   error #15527: loop was not vectorized: function call to fprintf cannot 
>> be vectorize
>>   #   was declared "deprecated"
>> -WERROR_FLAGS := -Wall -Werror-all -w2 -diag-disable 271 -diag-warning 1478
>> +WERROR_FLAGS := -Wall -w2 -diag-disable 271 -diag-warning 1478
>>   WERROR_FLAGS += -diag-disable 13368 -diag-disable 15527
>> +ifeq ($(CONFIG_RTE_ERROR_ON_WARNING),y)
>> +WERROR_FLAGS += -Werror-all
>> +endif
>> +
>>
>>   # process cpu flags
>>   include $(RTE_SDK)/mk/toolchain/$(RTE_TOOLCHAIN)/rte.toolchain-compat.mk
>
> The -Werror is a real feature. Having dealt with legacy code where
> there are lots of bugs which were already warnings being ignored, having
> a big hard stop when errors are found is really good.
>
> The default should be on but I understand why you may want to turn it
> off, but it should require some effort to do.

I wholeheartedly agree with all that, when applied the developers of the 
codebase. I spent the last 7+ years of my life working on a piece of 
software that emitted well over six hundred "harmless" warnings on build 
when I started with it, trust me I have very little tolerance for 
introducing new compiler warnings.

But 

[dpdk-dev] [PATCH 0/4] Broadcom 10G NIC Poll Mode Driver

2015-02-12 Thread Stephen Hemminger
On Thu, 12 Feb 2015 14:56:06 +
Thomas Monjalon  wrote:

> 2015-02-12 06:33, Stephen Hemminger:
> > On Thu, 12 Feb 2015 15:00:13 +0100
> > Thomas Monjalon  wrote:
> > 
> > > Hi Stephen,
> > > 
> > > 2015-02-07 07:15, Stephen Hemminger:
> > > > Source was from FreeBSD.
> > > > 
> > > > changes were to make it work and lots of de-uglification.
> > > 
> > > Maintenance would be eased by showing this work with separate commits.
> > > You should at least have a patch for importing FreeBSD source without
> > > modifications.
> > > 
> > > Other comment: there could be other drivers for Broadcom devices.
> > > Why not keeping the name bnx2x?
> > > 
> > > Thanks
> > 
> > That history is lost.
> 
> I don't understand your answer,
> and you forgot one question.
> Please reply below each question.
> 
> I said: "You should at least have a patch for importing FreeBSD source
> without modfications". Is the initial FreeBSD source lost?
> 
> Do you agree to rename to bnx2x?

This was based of driver called bxe in FreeBsd but the
changes are so massive that there is no point in creating such a
patch except to keep some lawyer happy.

 37 files changed, 33668 insertions(+), 159047 deletions(-)

It might be okay to rename the visible config option and directory
to bxe but not going to change internal things.



[dpdk-dev] [PATCH] mk: fix missing link of librte_vhost in shared, non-combined config

2015-02-12 Thread Thomas Monjalon
2015-02-11 12:31, Gonzalez Monroy, Sergio:
> From: Panu Matilainen [mailto:pmatilai at redhat.com]
> > On 02/11/2015 12:51 PM, Gonzalez Monroy, Sergio wrote:
> > > I think that vhost is being linked in the wrong place (plugins section).
> > > The plugins only get linked when building static libraries.
> > > I think the patch should also remove vhost from the plugins section.
> > 
> > Right, so vhost isn't a pluggable driver in the sense that pmds are. I wont
> > claim to be familiar with all this virt-related puzzle pieces :) I'll send 
> > an
> > updated patch, I was just looking to fix build in my particular config and
> > ignored the rest.
> > 
> > On a related note, shouldn't librte_pmd_bond and librte_pmd_xenvirt be
> > included in the plugins section along with all the other pmds?
> > 
> Hi Panu,
> 
> Good  question :)
> 
> I did wonder the same thing not long ago.
> 
> I think the reason is that (someone may correct me if I'm wrong) there
> are specific unit tests for those pmds (testing extra API) that require
> them to always be linked against.

A library is considered as a plugin if there is no public API and it
registers itself. That's the case of normal PMD.
But bonding and Xen have some library parts with public API.
It has been discussed and agreed for bonding but I'm not aware of the Xen case.


[dpdk-dev] [PATCH v2 09/11] lib/librte_vhost: vhost user support

2015-02-12 Thread Linhaifeng


On 2015/2/12 13:07, Huawei Xie wrote:
> +
> + /* This is ugly */
> + mapped_size = memory.regions[idx].memory_size +
> + memory.regions[idx].mmap_offset;
> + mapped_address = (uint64_t)(uintptr_t)mmap(NULL,
> + mapped_size,
> + PROT_READ | PROT_WRITE, MAP_SHARED,
> + pmsg->fds[idx],
> + 0);

Just another ugly way:
We can use the size of file to mmap then unmmap is not need align to the size 
of page.

-- 
Regards,
Haifeng



[dpdk-dev] [PATCH v5 17/19] ring: add support to non-EAL thread

2015-02-12 Thread Cunming Liang
ring debug stat won't take care non-EAL thread.

Signed-off-by: Cunming Liang 
---
 v5 changes:
   check __lcore_id with LCORE_ID_ANY instead of RTE_MAX_LCORE

 lib/librte_ring/rte_ring.h | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/lib/librte_ring/rte_ring.h b/lib/librte_ring/rte_ring.h
index 7cd5f2d..553a880 100644
--- a/lib/librte_ring/rte_ring.h
+++ b/lib/librte_ring/rte_ring.h
@@ -188,10 +188,12 @@ struct rte_ring {
  *   The number to add to the object-oriented statistics.
  */
 #ifdef RTE_LIBRTE_RING_DEBUG
-#define __RING_STAT_ADD(r, name, n) do {   \
-   unsigned __lcore_id = rte_lcore_id();   \
-   r->stats[__lcore_id].name##_objs += n;  \
-   r->stats[__lcore_id].name##_bulk += 1;  \
+#define __RING_STAT_ADD(r, name, n) do {\
+   unsigned __lcore_id = rte_lcore_id();   \
+   if (__lcore_id != LCORE_ID_ANY) {   \
+   r->stats[__lcore_id].name##_objs += n;  \
+   r->stats[__lcore_id].name##_bulk += 1;  \
+   }   \
} while(0)
 #else
 #define __RING_STAT_ADD(r, name, n) do {} while(0)
-- 
1.8.1.4



[dpdk-dev] [PATCH v5 16/19] mempool: add support to non-EAL thread

2015-02-12 Thread Cunming Liang
For non-EAL thread, bypass per lcore cache, directly use ring pool.
It allows using rte_mempool in either EAL thread or any user pthread.
As in non-EAL thread, it directly rely on rte_ring and it's none preemptive.
It doesn't suggest to run multi-pthread/cpu which compete the rte_mempool.
It will get bad performance and has critical risk if scheduling policy is RT.
Haven't found significant performance decrease by mempool_perf_test.

Signed-off-by: Cunming Liang 
---
 v5 changes:
   check __lcore_id with LCORE_ID_ANY instead of RTE_MAX_LCORE

 lib/librte_mempool/rte_mempool.h | 18 +++---
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h
index 3314651..2c0b960 100644
--- a/lib/librte_mempool/rte_mempool.h
+++ b/lib/librte_mempool/rte_mempool.h
@@ -198,10 +198,12 @@ struct rte_mempool {
  *   Number to add to the object-oriented statistics.
  */
 #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
-#define __MEMPOOL_STAT_ADD(mp, name, n) do {   \
-   unsigned __lcore_id = rte_lcore_id();   \
-   mp->stats[__lcore_id].name##_objs += n; \
-   mp->stats[__lcore_id].name##_bulk += 1; \
+#define __MEMPOOL_STAT_ADD(mp, name, n) do {\
+   unsigned __lcore_id = rte_lcore_id();   \
+   if (__lcore_id != LCORE_ID_ANY) {   \
+   mp->stats[__lcore_id].name##_objs += n; \
+   mp->stats[__lcore_id].name##_bulk += 1; \
+   }   \
} while(0)
 #else
 #define __MEMPOOL_STAT_ADD(mp, name, n) do {} while(0)
@@ -767,8 +769,9 @@ __mempool_put_bulk(struct rte_mempool *mp, void * const 
*obj_table,
__MEMPOOL_STAT_ADD(mp, put, n);

 #if RTE_MEMPOOL_CACHE_MAX_SIZE > 0
-   /* cache is not enabled or single producer */
-   if (unlikely(cache_size == 0 || is_mp == 0))
+   /* cache is not enabled or single producer or none EAL thread */
+   if (unlikely(cache_size == 0 || is_mp == 0 ||
+lcore_id == LCORE_ID_ANY))
goto ring_enqueue;

/* Go straight to ring if put would overflow mem allocated for cache */
@@ -952,7 +955,8 @@ __mempool_get_bulk(struct rte_mempool *mp, void **obj_table,
uint32_t cache_size = mp->cache_size;

/* cache is not enabled or single consumer */
-   if (unlikely(cache_size == 0 || is_mc == 0 || n >= cache_size))
+   if (unlikely(cache_size == 0 || is_mc == 0 ||
+n >= cache_size || lcore_id == LCORE_ID_ANY))
goto ring_dequeue;

cache = >local_cache[lcore_id];
-- 
1.8.1.4



[dpdk-dev] [PATCH v5 15/19] eal: fix recursive spinlock in non-EAL thraed

2015-02-12 Thread Cunming Liang
In non-EAL thread, lcore_id alrways be LCORE_ID_ANY.
It cann't be used as unique id for recursive spinlock.
Then use rte_gettid() to replace it.

Signed-off-by: Cunming Liang 
---
 lib/librte_eal/common/include/generic/rte_spinlock.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/librte_eal/common/include/generic/rte_spinlock.h 
b/lib/librte_eal/common/include/generic/rte_spinlock.h
index dea885c..c7fb0df 100644
--- a/lib/librte_eal/common/include/generic/rte_spinlock.h
+++ b/lib/librte_eal/common/include/generic/rte_spinlock.h
@@ -179,7 +179,7 @@ static inline void 
rte_spinlock_recursive_init(rte_spinlock_recursive_t *slr)
  */
 static inline void rte_spinlock_recursive_lock(rte_spinlock_recursive_t *slr)
 {
-   int id = rte_lcore_id();
+   int id = rte_gettid();

if (slr->user != id) {
rte_spinlock_lock(>sl);
@@ -212,7 +212,7 @@ static inline void 
rte_spinlock_recursive_unlock(rte_spinlock_recursive_t *slr)
  */
 static inline int rte_spinlock_recursive_trylock(rte_spinlock_recursive_t *slr)
 {
-   int id = rte_lcore_id();
+   int id = rte_gettid();

if (slr->user != id) {
if (rte_spinlock_trylock(>sl) == 0)
-- 
1.8.1.4



[dpdk-dev] [PATCH v5 14/19] eal: set _lcore_id and _socket_id to (-1) by default

2015-02-12 Thread Cunming Liang
For those none EAL thread, *_lcore_id* shall always be LCORE_ID_ANY.
The libraries using *_lcore_id* as index need to take care.
*_socket_id* always be SOCKET_ID_ANY unitl the thread changes the affinity
by rte_thread_set_affinity()

Signed-off-by: Cunming Liang 
---
 v5 changes:
define LCORE_ID_ANY as UINT32_MAX  

 lib/librte_eal/bsdapp/eal/eal_thread.c| 4 ++--
 lib/librte_eal/common/include/rte_lcore.h | 4 ++--
 lib/librte_eal/linuxapp/eal/eal_thread.c  | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/lib/librte_eal/bsdapp/eal/eal_thread.c 
b/lib/librte_eal/bsdapp/eal/eal_thread.c
index e16f685..ca95c72 100644
--- a/lib/librte_eal/bsdapp/eal/eal_thread.c
+++ b/lib/librte_eal/bsdapp/eal/eal_thread.c
@@ -56,8 +56,8 @@
 #include "eal_private.h"
 #include "eal_thread.h"

-RTE_DEFINE_PER_LCORE(unsigned, _lcore_id);
-RTE_DEFINE_PER_LCORE(unsigned, _socket_id);
+RTE_DEFINE_PER_LCORE(unsigned, _lcore_id) = LCORE_ID_ANY;
+RTE_DEFINE_PER_LCORE(unsigned, _socket_id) = (unsigned)SOCKET_ID_ANY;
 RTE_DEFINE_PER_LCORE(rte_cpuset_t, _cpuset);

 /*
diff --git a/lib/librte_eal/common/include/rte_lcore.h 
b/lib/librte_eal/common/include/rte_lcore.h
index 6a5bcbc..ad47221 100644
--- a/lib/librte_eal/common/include/rte_lcore.h
+++ b/lib/librte_eal/common/include/rte_lcore.h
@@ -48,7 +48,7 @@
 extern "C" {
 #endif

-#define LCORE_ID_ANY -1/**< Any lcore. */
+#define LCORE_ID_ANY UINT32_MAX   /**< Any lcore. */

 #if defined(__linux__)
typedef cpu_set_t rte_cpuset_t;
@@ -87,7 +87,7 @@ RTE_DECLARE_PER_LCORE(rte_cpuset_t, _cpuset); /**< Per thread 
"cpuset". */
 /**
  * Return the ID of the execution unit we are running on.
  * @return
- *  Logical core ID
+ *  Logical core ID(in EAL thread) or LCORE_ID_ANY(in non-EAL thread)
  */
 static inline unsigned
 rte_lcore_id(void)
diff --git a/lib/librte_eal/linuxapp/eal/eal_thread.c 
b/lib/librte_eal/linuxapp/eal/eal_thread.c
index 57b0515..5635c7d 100644
--- a/lib/librte_eal/linuxapp/eal/eal_thread.c
+++ b/lib/librte_eal/linuxapp/eal/eal_thread.c
@@ -56,8 +56,8 @@
 #include "eal_private.h"
 #include "eal_thread.h"

-RTE_DEFINE_PER_LCORE(unsigned, _lcore_id);
-RTE_DEFINE_PER_LCORE(unsigned, _socket_id);
+RTE_DEFINE_PER_LCORE(unsigned, _lcore_id) = LCORE_ID_ANY;
+RTE_DEFINE_PER_LCORE(unsigned, _socket_id) = (unsigned)SOCKET_ID_ANY;
 RTE_DEFINE_PER_LCORE(rte_cpuset_t, _cpuset);

 /*
-- 
1.8.1.4



[dpdk-dev] [PATCH v5 13/19] log: fix the gap to support non-EAL thread

2015-02-12 Thread Cunming Liang
For those non-EAL thread, *_lcore_id* is invalid and probably larger than 
RTE_MAX_LCORE.
The patch adds the check and allows only EAL thread using EAL per thread log 
level and log type.
Others shares the global log level.

Signed-off-by: Cunming Liang 
---
 lib/librte_eal/common/eal_common_log.c  | 17 +++--
 lib/librte_eal/common/include/rte_log.h |  5 +
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_log.c 
b/lib/librte_eal/common/eal_common_log.c
index cf57619..e8dc94a 100644
--- a/lib/librte_eal/common/eal_common_log.c
+++ b/lib/librte_eal/common/eal_common_log.c
@@ -193,11 +193,20 @@ rte_set_log_type(uint32_t type, int enable)
rte_logs.type &= (~type);
 }

+/* Get global log type */
+uint32_t
+rte_get_log_type(void)
+{
+   return rte_logs.type;
+}
+
 /* get the current loglevel for the message beeing processed */
 int rte_log_cur_msg_loglevel(void)
 {
unsigned lcore_id;
lcore_id = rte_lcore_id();
+   if (lcore_id >= RTE_MAX_LCORE)
+   return rte_get_log_level();
return log_cur_msg[lcore_id].loglevel;
 }

@@ -206,6 +215,8 @@ int rte_log_cur_msg_logtype(void)
 {
unsigned lcore_id;
lcore_id = rte_lcore_id();
+   if (lcore_id >= RTE_MAX_LCORE)
+   return rte_get_log_type();
return log_cur_msg[lcore_id].logtype;
 }

@@ -265,8 +276,10 @@ rte_vlog(__attribute__((unused)) uint32_t level,

/* save loglevel and logtype in a global per-lcore variable */
lcore_id = rte_lcore_id();
-   log_cur_msg[lcore_id].loglevel = level;
-   log_cur_msg[lcore_id].logtype = logtype;
+   if (lcore_id < RTE_MAX_LCORE) {
+   log_cur_msg[lcore_id].loglevel = level;
+   log_cur_msg[lcore_id].logtype = logtype;
+   }

ret = vfprintf(f, format, ap);
fflush(f);
diff --git a/lib/librte_eal/common/include/rte_log.h 
b/lib/librte_eal/common/include/rte_log.h
index db1ea08..f83a0d9 100644
--- a/lib/librte_eal/common/include/rte_log.h
+++ b/lib/librte_eal/common/include/rte_log.h
@@ -144,6 +144,11 @@ uint32_t rte_get_log_level(void);
 void rte_set_log_type(uint32_t type, int enable);

 /**
+ * Get the global log type.
+ */
+uint32_t rte_get_log_type(void);
+
+/**
  * Get the current loglevel for the message being processed.
  *
  * Before calling the user-defined stream for logging, the log
-- 
1.8.1.4



[dpdk-dev] [PATCH v5 12/19] malloc: fix the issue of SOCKET_ID_ANY

2015-02-12 Thread Cunming Liang
Add check for rte_socket_id(), avoid get unexpected return like (-1).

Signed-off-by: Cunming Liang 
---
 lib/librte_malloc/malloc_heap.h | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lib/librte_malloc/malloc_heap.h b/lib/librte_malloc/malloc_heap.h
index b4aec45..a47136d 100644
--- a/lib/librte_malloc/malloc_heap.h
+++ b/lib/librte_malloc/malloc_heap.h
@@ -44,7 +44,12 @@ extern "C" {
 static inline unsigned
 malloc_get_numa_socket(void)
 {
-   return rte_socket_id();
+   unsigned socket_id = rte_socket_id();
+
+   if (socket_id == (unsigned)SOCKET_ID_ANY)
+   return 0;
+
+   return socket_id;
 }

 void *
-- 
1.8.1.4



[dpdk-dev] [PATCH v5 11/19] enic: fix re-define freebsd compile complain

2015-02-12 Thread Cunming Liang
Some macro already been defined by freebsd 'sys/param.h'.

Signed-off-by: Cunming Liang 
---
 v5 changes:
   rename the redefined MACRO instead of undefine them

 lib/librte_pmd_enic/enic.h  | 4 ++--
 lib/librte_pmd_enic/enic_compat.h   | 2 +-
 lib/librte_pmd_enic/vnic/vnic_dev.c | 6 +++---
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/lib/librte_pmd_enic/enic.h b/lib/librte_pmd_enic/enic.h
index c43417c..57b9c80 100644
--- a/lib/librte_pmd_enic/enic.h
+++ b/lib/librte_pmd_enic/enic.h
@@ -66,9 +66,9 @@
 #define ENIC_CALC_IP_CKSUM  1
 #define ENIC_CALC_TCP_UDP_CKSUM 2
 #define ENIC_MAX_MTU9000
-#define PAGE_SIZE   4096
+#define ENIC_PAGE_SIZE  4096
 #define PAGE_ROUND_UP(x) \
-   unsigned long)(x)) + PAGE_SIZE-1) & (~(PAGE_SIZE-1)))
+   unsigned long)(x)) + ENIC_PAGE_SIZE-1) & (~(ENIC_PAGE_SIZE-1)))

 #define ENICPMD_VFIO_PATH  "/dev/vfio/vfio"
 /*#define ENIC_DESC_COUNT_MAKE_ODD (x) do{if ((~(x)) & 1) { (x)--; } 
}while(0)*/
diff --git a/lib/librte_pmd_enic/enic_compat.h 
b/lib/librte_pmd_enic/enic_compat.h
index b1af838..40c9b44 100644
--- a/lib/librte_pmd_enic/enic_compat.h
+++ b/lib/librte_pmd_enic/enic_compat.h
@@ -67,7 +67,7 @@
 #define pr_warn(y, args...) dev_warning(0, y, ##args)
 #define BUG() pr_err("BUG at %s:%d", __func__, __LINE__)

-#define ALIGN(x, a)  __ALIGN_MASK(x, (typeof(x))(a)-1)
+#define VNIC_ALIGN(x, a) __ALIGN_MASK(x, (typeof(x))(a)-1)
 #define __ALIGN_MASK(x, mask)(((x)+(mask))&~(mask))
 #define udelay usleep
 #define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
diff --git a/lib/librte_pmd_enic/vnic/vnic_dev.c 
b/lib/librte_pmd_enic/vnic/vnic_dev.c
index 6407994..38b7f25 100644
--- a/lib/librte_pmd_enic/vnic/vnic_dev.c
+++ b/lib/librte_pmd_enic/vnic/vnic_dev.c
@@ -242,9 +242,9 @@ unsigned int vnic_dev_desc_ring_size(struct vnic_dev_ring 
*ring,
if (desc_count == 0)
desc_count = 4096;

-   ring->desc_count = ALIGN(desc_count, count_align);
+   ring->desc_count = VNIC_ALIGN(desc_count, count_align);

-   ring->desc_size = ALIGN(desc_size, desc_align);
+   ring->desc_size = VNIC_ALIGN(desc_size, desc_align);

ring->size = ring->desc_count * ring->desc_size;
ring->size_unaligned = ring->size + ring->base_align;
@@ -294,7 +294,7 @@ int vnic_dev_alloc_desc_ring(__attribute__((unused)) struct 
vnic_dev *vdev,

ring->base_addr_unaligned = (dma_addr_t)rz->phys_addr;

-   ring->base_addr = ALIGN(ring->base_addr_unaligned,
+   ring->base_addr = VNIC_ALIGN(ring->base_addr_unaligned,
ring->base_align);
ring->descs = (u8 *)ring->descs_unaligned +
(ring->base_addr - ring->base_addr_unaligned);
-- 
1.8.1.4



[dpdk-dev] [PATCH v5 10/19] eal: apply affinity of EAL thread by assigned cpuset

2015-02-12 Thread Cunming Liang
EAL threads use assigned cpuset to set core affinity during startup.
It keeps 1:1 mapping, if no '--lcores' option is used.

Signed-off-by: Cunming Liang 
---
 v5 changes:
   add return check for dump_affinity
   call rte_thread_set_affinity() directly during EAL thread set

 lib/librte_eal/bsdapp/eal/eal.c   | 10 +++--
 lib/librte_eal/bsdapp/eal/eal_thread.c| 64 ++
 lib/librte_eal/common/include/rte_lcore.h |  2 +-
 lib/librte_eal/linuxapp/eal/eal.c |  8 +++-
 lib/librte_eal/linuxapp/eal/eal_thread.c  | 66 ++-
 5 files changed, 37 insertions(+), 113 deletions(-)

diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c
index cb11b5c..b66f6c6 100644
--- a/lib/librte_eal/bsdapp/eal/eal.c
+++ b/lib/librte_eal/bsdapp/eal/eal.c
@@ -432,6 +432,7 @@ rte_eal_init(int argc, char **argv)
int i, fctret, ret;
pthread_t thread_id;
static rte_atomic32_t run_once = RTE_ATOMIC32_INIT(0);
+   char cpuset[RTE_CPU_AFFINITY_STR_LEN];

if (!rte_atomic32_test_and_set(_once))
return -1;
@@ -502,15 +503,18 @@ rte_eal_init(int argc, char **argv)
if (rte_eal_pci_init() < 0)
rte_panic("Cannot init PCI\n");

-   RTE_LOG(DEBUG, EAL, "Master core %u is ready (tid=%p)\n",
-   rte_config.master_lcore, thread_id);
-
eal_check_mem_on_local_socket();

rte_eal_mcfg_complete();

eal_thread_init_master(rte_config.master_lcore);

+   ret = eal_thread_dump_affinity(cpuset, RTE_CPU_AFFINITY_STR_LEN);
+
+   RTE_LOG(DEBUG, EAL, "Master lcore %u is ready (tid=%p;cpuset=[%s%s])\n",
+   rte_config.master_lcore, thread_id, cpuset,
+   ret == 0 ? "" : "...");
+
if (rte_eal_dev_init() < 0)
rte_panic("Cannot init pmd devices\n");

diff --git a/lib/librte_eal/bsdapp/eal/eal_thread.c 
b/lib/librte_eal/bsdapp/eal/eal_thread.c
index d0c077b..e16f685 100644
--- a/lib/librte_eal/bsdapp/eal/eal_thread.c
+++ b/lib/librte_eal/bsdapp/eal/eal_thread.c
@@ -101,58 +101,13 @@ rte_eal_remote_launch(int (*f)(void *), void *arg, 
unsigned slave_id)
 static int
 eal_thread_set_affinity(void)
 {
-   int s;
-   pthread_t thread;
+   unsigned lcore_id = rte_lcore_id();

-/*
- * According to the section VERSIONS of the CPU_ALLOC man page:
- *
- * The CPU_ZERO(), CPU_SET(), CPU_CLR(), and CPU_ISSET() macros were added
- * in glibc 2.3.3.
- *
- * CPU_COUNT() first appeared in glibc 2.6.
- *
- * CPU_AND(), CPU_OR(), CPU_XOR(),CPU_EQUAL(),CPU_ALLOC(),
- * CPU_ALLOC_SIZE(), CPU_FREE(), CPU_ZERO_S(),  CPU_SET_S(),  CPU_CLR_S(),
- * CPU_ISSET_S(),  CPU_AND_S(), CPU_OR_S(), CPU_XOR_S(), and CPU_EQUAL_S()
- * first appeared in glibc 2.7.
- */
-#if defined(CPU_ALLOC)
-   size_t size;
-   cpu_set_t *cpusetp;
-
-   cpusetp = CPU_ALLOC(RTE_MAX_LCORE);
-   if (cpusetp == NULL) {
-   RTE_LOG(ERR, EAL, "CPU_ALLOC failed\n");
-   return -1;
-   }
-
-   size = CPU_ALLOC_SIZE(RTE_MAX_LCORE);
-   CPU_ZERO_S(size, cpusetp);
-   CPU_SET_S(rte_lcore_id(), size, cpusetp);
+   /* acquire system unique id  */
+   rte_gettid();

-   thread = pthread_self();
-   s = pthread_setaffinity_np(thread, size, cpusetp);
-   if (s != 0) {
-   RTE_LOG(ERR, EAL, "pthread_setaffinity_np failed\n");
-   CPU_FREE(cpusetp);
-   return -1;
-   }
-
-   CPU_FREE(cpusetp);
-#else /* CPU_ALLOC */
-   cpuset_t cpuset;
-   CPU_ZERO(  );
-   CPU_SET( rte_lcore_id(),  );
-
-   thread = pthread_self();
-   s = pthread_setaffinity_np(thread, sizeof( cpuset ), );
-   if (s != 0) {
-   RTE_LOG(ERR, EAL, "pthread_setaffinity_np failed\n");
-   return -1;
-   }
-#endif
-   return 0;
+   /* update EAL thread core affinity */
+   return rte_thread_set_affinity(_config[lcore_id].cpuset);
 }

 void eal_thread_init_master(unsigned lcore_id)
@@ -174,6 +129,7 @@ eal_thread_loop(__attribute__((unused)) void *arg)
unsigned lcore_id;
pthread_t thread_id;
int m2s, s2m;
+   char cpuset[RTE_CPU_AFFINITY_STR_LEN];

thread_id = pthread_self();

@@ -185,9 +141,6 @@ eal_thread_loop(__attribute__((unused)) void *arg)
if (lcore_id == RTE_MAX_LCORE)
rte_panic("cannot retrieve lcore id\n");

-   RTE_LOG(DEBUG, EAL, "Core %u is ready (tid=%p)\n",
-   lcore_id, thread_id);
-
m2s = lcore_config[lcore_id].pipe_master2slave[0];
s2m = lcore_config[lcore_id].pipe_slave2master[1];

@@ -198,6 +151,11 @@ eal_thread_loop(__attribute__((unused)) void *arg)
if (eal_thread_set_affinity() < 0)
rte_panic("cannot set affinity\n");

+   ret = eal_thread_dump_affinity(cpuset, RTE_CPU_AFFINITY_STR_LEN);
+
+   RTE_LOG(DEBUG, EAL, "lcore %u is ready (tid=%p;cpuset=[%s%s])\n",
+   

[dpdk-dev] [PATCH v5 09/19] eal: add rte_gettid() to acquire unique system tid

2015-02-12 Thread Cunming Liang
The rte_gettid() wraps the linux and freebsd syscall gettid().
It provides a persistent unique thread id for the calling thread.
It will save the unique id in TLS on the first time.

Signed-off-by: Cunming Liang 
---
 lib/librte_eal/bsdapp/eal/eal_thread.c   |  9 +
 lib/librte_eal/common/include/rte_eal.h  | 27 +++
 lib/librte_eal/linuxapp/eal/eal_thread.c |  7 +++
 3 files changed, 43 insertions(+)

diff --git a/lib/librte_eal/bsdapp/eal/eal_thread.c 
b/lib/librte_eal/bsdapp/eal/eal_thread.c
index 10220c7..d0c077b 100644
--- a/lib/librte_eal/bsdapp/eal/eal_thread.c
+++ b/lib/librte_eal/bsdapp/eal/eal_thread.c
@@ -39,6 +39,7 @@
 #include 
 #include 
 #include 
+#include 

 #include 
 #include 
@@ -233,3 +234,11 @@ eal_thread_loop(__attribute__((unused)) void *arg)
/* pthread_exit(NULL); */
/* return NULL; */
 }
+
+/* require calling thread tid by gettid() */
+int rte_sys_gettid(void)
+{
+   long lwpid;
+   thr_self();
+   return (int)lwpid;
+}
diff --git a/lib/librte_eal/common/include/rte_eal.h 
b/lib/librte_eal/common/include/rte_eal.h
index f4ecd2e..8ccdd65 100644
--- a/lib/librte_eal/common/include/rte_eal.h
+++ b/lib/librte_eal/common/include/rte_eal.h
@@ -41,6 +41,9 @@
  */

 #include 
+#include 
+
+#include 

 #ifdef __cplusplus
 extern "C" {
@@ -262,6 +265,30 @@ rte_set_application_usage_hook( rte_usage_hook_t 
usage_func );
  */
 int rte_eal_has_hugepages(void);

+/**
+ * A wrap API for syscall gettid.
+ *
+ * @return
+ *   On success, returns the thread ID of calling process.
+ *   It always successful.
+ */
+int rte_sys_gettid(void);
+
+/**
+ * Get system unique thread id.
+ *
+ * @return
+ *   On success, returns the thread ID of calling process.
+ *   It always successful.
+ */
+static inline int rte_gettid(void)
+{
+   static RTE_DEFINE_PER_LCORE(int, _thread_id) = -1;
+   if (RTE_PER_LCORE(_thread_id) == -1)
+   RTE_PER_LCORE(_thread_id) = rte_sys_gettid();
+   return RTE_PER_LCORE(_thread_id);
+}
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/librte_eal/linuxapp/eal/eal_thread.c 
b/lib/librte_eal/linuxapp/eal/eal_thread.c
index 748a83a..ed20c93 100644
--- a/lib/librte_eal/linuxapp/eal/eal_thread.c
+++ b/lib/librte_eal/linuxapp/eal/eal_thread.c
@@ -39,6 +39,7 @@
 #include 
 #include 
 #include 
+#include 

 #include 
 #include 
@@ -233,3 +234,9 @@ eal_thread_loop(__attribute__((unused)) void *arg)
/* pthread_exit(NULL); */
/* return NULL; */
 }
+
+/* require calling thread tid by gettid() */
+int rte_sys_gettid(void)
+{
+   return (int)syscall(SYS_gettid);
+}
-- 
1.8.1.4



[dpdk-dev] [PATCH v5 08/19] eal: standardize init sequence between linux and bsd

2015-02-12 Thread Cunming Liang

Signed-off-by: Cunming Liang 
---
 lib/librte_eal/bsdapp/eal/eal.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c
index 69f3c03..cb11b5c 100644
--- a/lib/librte_eal/bsdapp/eal/eal.c
+++ b/lib/librte_eal/bsdapp/eal/eal.c
@@ -509,6 +509,8 @@ rte_eal_init(int argc, char **argv)

rte_eal_mcfg_complete();

+   eal_thread_init_master(rte_config.master_lcore);
+
if (rte_eal_dev_init() < 0)
rte_panic("Cannot init pmd devices\n");

@@ -532,8 +534,6 @@ rte_eal_init(int argc, char **argv)
rte_panic("Cannot create thread\n");
}

-   eal_thread_init_master(rte_config.master_lcore);
-
/*
 * Launch a dummy function on all slave lcores, so that master lcore
 * knows they are all ready when this function returns.
-- 
1.8.1.4



[dpdk-dev] [PATCH v5 07/19] eal: add eal_common_thread.c for common thread API

2015-02-12 Thread Cunming Liang
The API works for both EAL thread and none EAL thread.
When calling rte_thread_set_affinity, the *_socket_id* and
*_cpuset* of calling thread will be updated if the thread
successful set the cpu affinity.

Signed-off-by: Cunming Liang 
---
 v5 changes:
   refine code of rte_thread_set_affinity()
   change rte_thread_get_affinity() return to void

 lib/librte_eal/bsdapp/eal/Makefile|   1 +
 lib/librte_eal/common/eal_common_thread.c | 150 ++
 lib/librte_eal/linuxapp/eal/Makefile  |   2 +
 3 files changed, 153 insertions(+)
 create mode 100644 lib/librte_eal/common/eal_common_thread.c

diff --git a/lib/librte_eal/bsdapp/eal/Makefile 
b/lib/librte_eal/bsdapp/eal/Makefile
index ae214a4..2357cfa 100644
--- a/lib/librte_eal/bsdapp/eal/Makefile
+++ b/lib/librte_eal/bsdapp/eal/Makefile
@@ -77,6 +77,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_hexdump.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_devargs.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_dev.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_options.c
+SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_thread.c

 CFLAGS_eal.o := -D_GNU_SOURCE
 #CFLAGS_eal_thread.o := -D_GNU_SOURCE
diff --git a/lib/librte_eal/common/eal_common_thread.c 
b/lib/librte_eal/common/eal_common_thread.c
new file mode 100644
index 000..f4d9892
--- /dev/null
+++ b/lib/librte_eal/common/eal_common_thread.c
@@ -0,0 +1,150 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+ *   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 Intel 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 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include "eal_thread.h"
+
+int eal_cpuset_socket_id(rte_cpuset_t *cpusetp)
+{
+   unsigned cpu = 0;
+   int socket_id = SOCKET_ID_ANY;
+   int sid;
+
+   if (cpusetp == NULL)
+   return SOCKET_ID_ANY;
+
+   do {
+   if (!CPU_ISSET(cpu, cpusetp))
+   continue;
+
+   if (socket_id == SOCKET_ID_ANY)
+   socket_id = eal_cpu_socket_id(cpu);
+
+   sid = eal_cpu_socket_id(cpu);
+   if (socket_id != sid) {
+   socket_id = SOCKET_ID_ANY;
+   break;
+   }
+
+   } while (++cpu < RTE_MAX_LCORE);
+
+   return socket_id;
+}
+
+int
+rte_thread_set_affinity(rte_cpuset_t *cpusetp)
+{
+   int s;
+   unsigned lcore_id;
+   pthread_t tid;
+
+   tid = pthread_self();
+
+   s = pthread_setaffinity_np(tid, sizeof(rte_cpuset_t), cpusetp);
+   if (s != 0) {
+   RTE_LOG(ERR, EAL, "pthread_setaffinity_np failed\n");
+   return -1;
+   }
+
+   /* store socket_id in TLS for quick access */
+   RTE_PER_LCORE(_socket_id) =
+   eal_cpuset_socket_id(cpusetp);
+
+   /* store cpuset in TLS for quick access */
+   memmove(_PER_LCORE(_cpuset), cpusetp,
+   sizeof(rte_cpuset_t));
+
+   lcore_id = rte_lcore_id();
+   if (lcore_id != (unsigned)LCORE_ID_ANY) {
+   /* EAL thread will update lcore_config */
+   lcore_config[lcore_id].socket_id = RTE_PER_LCORE(_socket_id);
+   memmove(_config[lcore_id].cpuset, cpusetp,
+   sizeof(rte_cpuset_t));
+   }
+
+   return 0;
+}
+
+void

[dpdk-dev] [PATCH v5 06/19] eal: new TLS definition and API declaration

2015-02-12 Thread Cunming Liang
1. add two TLS *_socket_id* and *_cpuset*
2. add two external API rte_thread_set/get_affinity
3. add one internal API eal_thread_dump_affinity

Signed-off-by: Cunming Liang 
---
 v5 changes:
   add comments for RTE_CPU_AFFINITY_STR_LEN
   update comments for eal_thread_dump_affinity()
   return void for rte_thread_get_affinity()
   move rte_socket_id() change to another patch

 lib/librte_eal/bsdapp/eal/eal_thread.c|  2 ++
 lib/librte_eal/common/eal_thread.h| 36 +++
 lib/librte_eal/common/include/rte_lcore.h | 26 +-
 lib/librte_eal/linuxapp/eal/eal_thread.c  |  2 ++
 4 files changed, 65 insertions(+), 1 deletion(-)

diff --git a/lib/librte_eal/bsdapp/eal/eal_thread.c 
b/lib/librte_eal/bsdapp/eal/eal_thread.c
index ab05368..10220c7 100644
--- a/lib/librte_eal/bsdapp/eal/eal_thread.c
+++ b/lib/librte_eal/bsdapp/eal/eal_thread.c
@@ -56,6 +56,8 @@
 #include "eal_thread.h"

 RTE_DEFINE_PER_LCORE(unsigned, _lcore_id);
+RTE_DEFINE_PER_LCORE(unsigned, _socket_id);
+RTE_DEFINE_PER_LCORE(rte_cpuset_t, _cpuset);

 /*
  * Send a message to a slave lcore identified by slave_id to call a
diff --git a/lib/librte_eal/common/eal_thread.h 
b/lib/librte_eal/common/eal_thread.h
index f1ce0bd..e4e76b9 100644
--- a/lib/librte_eal/common/eal_thread.h
+++ b/lib/librte_eal/common/eal_thread.h
@@ -34,6 +34,8 @@
 #ifndef EAL_THREAD_H
 #define EAL_THREAD_H

+#include 
+
 /**
  * basic loop of thread, called for each thread by eal_init().
  *
@@ -61,4 +63,38 @@ void eal_thread_init_master(unsigned lcore_id);
  */
 unsigned eal_cpu_socket_id(unsigned cpu_id);

+/**
+ * Get the NUMA socket id from cpuset.
+ * This function is private to EAL.
+ *
+ * @param cpusetp
+ *   The point to a valid cpu set.
+ * @return
+ *   socket_id or SOCKET_ID_ANY
+ */
+int eal_cpuset_socket_id(rte_cpuset_t *cpusetp);
+
+/**
+ * Default buffer size to use with eal_thread_dump_affinity()
+ */
+#define RTE_CPU_AFFINITY_STR_LEN256
+
+/**
+ * Dump the current pthread cpuset.
+ * This function is private to EAL.
+ *
+ * Note:
+ *   If the dump size is greater than the size of given buffer,
+ *   the string will be truncated and with '\0' at the end.
+ *
+ * @param str
+ *   The string buffer the cpuset will dump to.
+ * @param size
+ *   The string buffer size.
+ * @return
+ *   0 for success, -1 if truncation happens.
+ */
+int
+eal_thread_dump_affinity(char *str, unsigned size);
+
 #endif /* EAL_THREAD_H */
diff --git a/lib/librte_eal/common/include/rte_lcore.h 
b/lib/librte_eal/common/include/rte_lcore.h
index 4c7d6bb..33f558e 100644
--- a/lib/librte_eal/common/include/rte_lcore.h
+++ b/lib/librte_eal/common/include/rte_lcore.h
@@ -80,7 +80,9 @@ struct lcore_config {
  */
 extern struct lcore_config lcore_config[RTE_MAX_LCORE];

-RTE_DECLARE_PER_LCORE(unsigned, _lcore_id); /**< Per core "core id". */
+RTE_DECLARE_PER_LCORE(unsigned, _lcore_id);  /**< Per thread "lcore id". */
+RTE_DECLARE_PER_LCORE(unsigned, _socket_id); /**< Per thread "socket id". */
+RTE_DECLARE_PER_LCORE(rte_cpuset_t, _cpuset); /**< Per thread "cpuset". */

 /**
  * Return the ID of the execution unit we are running on.
@@ -229,6 +231,28 @@ rte_get_next_lcore(unsigned i, int skip_master, int wrap)
 i

[dpdk-dev] [PATCH v5 05/19] eal: add support parsing socket_id from cpuset

2015-02-12 Thread Cunming Liang
It returns the socket_id if all cpus in the cpuset belongs
to the same NUMA node, otherwise it will return SOCKET_ID_ANY.

Signed-off-by: Cunming Liang 
---
 v5 changes:
   expose cpu_socket_id as eal_cpu_socket_id for linuxapp
   eal_cpuset_socket_id() remove static inline and move to c file

 lib/librte_eal/bsdapp/eal/eal_lcore.c   |  7 +++
 lib/librte_eal/common/eal_thread.h  | 11 +++
 lib/librte_eal/linuxapp/eal/eal_lcore.c |  7 ---
 3 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/lib/librte_eal/bsdapp/eal/eal_lcore.c 
b/lib/librte_eal/bsdapp/eal/eal_lcore.c
index 72f8ac2..162fb4f 100644
--- a/lib/librte_eal/bsdapp/eal/eal_lcore.c
+++ b/lib/librte_eal/bsdapp/eal/eal_lcore.c
@@ -41,6 +41,7 @@
 #include 

 #include "eal_private.h"
+#include "eal_thread.h"

 /* No topology information available on FreeBSD including NUMA info */
 #define cpu_core_id(X) 0
@@ -112,3 +113,9 @@ rte_eal_cpu_init(void)

return 0;
 }
+
+unsigned
+eal_cpu_socket_id(__rte_unused unsigned cpu_id)
+{
+   return cpu_socket_id(cpu_id);
+}
diff --git a/lib/librte_eal/common/eal_thread.h 
b/lib/librte_eal/common/eal_thread.h
index b53b84d..f1ce0bd 100644
--- a/lib/librte_eal/common/eal_thread.h
+++ b/lib/librte_eal/common/eal_thread.h
@@ -50,4 +50,15 @@ __attribute__((noreturn)) void *eal_thread_loop(void *arg);
  */
 void eal_thread_init_master(unsigned lcore_id);

+/**
+ * Get the NUMA socket id from cpu id.
+ * This function is private to EAL.
+ *
+ * @param cpu_id
+ *   The logical process id.
+ * @return
+ *   socket_id or SOCKET_ID_ANY
+ */
+unsigned eal_cpu_socket_id(unsigned cpu_id);
+
 #endif /* EAL_THREAD_H */
diff --git a/lib/librte_eal/linuxapp/eal/eal_lcore.c 
b/lib/librte_eal/linuxapp/eal/eal_lcore.c
index 29615f8..ef8c433 100644
--- a/lib/librte_eal/linuxapp/eal/eal_lcore.c
+++ b/lib/librte_eal/linuxapp/eal/eal_lcore.c
@@ -45,6 +45,7 @@

 #include "eal_private.h"
 #include "eal_filesystem.h"
+#include "eal_thread.h"

 #define SYS_CPU_DIR "/sys/devices/system/cpu/cpu%u"
 #define CORE_ID_FILE "topology/core_id"
@@ -71,8 +72,8 @@ cpu_detected(unsigned lcore_id)
  * Note: physical package id != NUMA node, but we use it as a
  * fallback for kernels which don't create a nodeY link
  */
-static unsigned
-cpu_socket_id(unsigned lcore_id)
+unsigned
+eal_cpu_socket_id(unsigned lcore_id)
 {
const char node_prefix[] = "node";
const size_t prefix_len = sizeof(node_prefix) - 1;
@@ -174,7 +175,7 @@ rte_eal_cpu_init(void)
/* By default, each detected core is enabled */
config->lcore_role[lcore_id] = ROLE_RTE;
lcore_config[lcore_id].core_id = cpu_core_id(lcore_id);
-   lcore_config[lcore_id].socket_id = cpu_socket_id(lcore_id);
+   lcore_config[lcore_id].socket_id = eal_cpu_socket_id(lcore_id);
if (lcore_config[lcore_id].socket_id >= RTE_MAX_NUMA_NODES)
 #ifdef RTE_EAL_ALLOW_INV_SOCKET_ID
lcore_config[lcore_id].socket_id = 0;
-- 
1.8.1.4



[dpdk-dev] [PATCH v5 04/19] eal: fix wrong strnlen() return value in 32bit icc

2015-02-12 Thread Cunming Liang
The problem is that strnlen() here may return invalid value with 32bit icc.
(actually it returns it?s second parameter,e.g: sysconf(_SC_ARG_MAX)).
It starts to manifest hwen max_len parameter is > 2M and using icc ?m32 ?O2 (or 
above).

Suggested-by: Konstantin Ananyev 
Signed-off-by: Cunming Liang 
---
 v5 changes:
   using strlen instead of strnlen.

 lib/librte_eal/common/eal_common_options.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_options.c 
b/lib/librte_eal/common/eal_common_options.c
index 178e303..9cf2faa 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -167,7 +167,7 @@ eal_parse_coremask(const char *coremask)
if (coremask[0] == '0' && ((coremask[1] == 'x')
|| (coremask[1] == 'X')))
coremask += 2;
-   i = strnlen(coremask, PATH_MAX);
+   i = strlen(coremask);
while ((i > 0) && isblank(coremask[i - 1]))
i--;
if (i == 0)
@@ -227,7 +227,7 @@ eal_parse_corelist(const char *corelist)
/* Remove all blank characters ahead and after */
while (isblank(*corelist))
corelist++;
-   i = strnlen(corelist, sysconf(_SC_ARG_MAX));
+   i = strlen(corelist);
while ((i > 0) && isblank(corelist[i - 1]))
i--;

@@ -472,7 +472,7 @@ eal_parse_lcores(const char *lcores)
/* Remove all blank characters ahead and after */
while (isblank(*lcores))
lcores++;
-   i = strnlen(lcores, sysconf(_SC_ARG_MAX));
+   i = strlen(lcores);
while ((i > 0) && isblank(lcores[i - 1]))
i--;

-- 
1.8.1.4



[dpdk-dev] [PATCH v5 03/19] eal: new eal option '--lcores' for cpu assignment

2015-02-12 Thread Cunming Liang
It supports one new eal long option '--lcores' for EAL thread cpuset assignment.

The format pattern:
--lcores='lcores[@cpus]<,lcores[@cpus]>'
lcores, cpus could be a single digit/range or a group.
'(' and ')' are necessary if it's a group.
If not supply '@cpus', the value of cpus uses the same as lcores.

e.g. '1,2@(5-7),(3-5)@(0,2),(0,6),7-8' means starting 9 EAL thread as below
  lcore 0 runs on cpuset 0x41 (cpu 0,6)
  lcore 1 runs on cpuset 0x2 (cpu 1)
  lcore 2 runs on cpuset 0xe0 (cpu 5,6,7)
  lcore 3,4,5 runs on cpuset 0x5 (cpu 0,2)
  lcore 6 runs on cpuset 0x41 (cpu 0,6)
  lcore 7 runs on cpuset 0x80 (cpu 7)
  lcore 8 runs on cpuset 0x100 (cpu 8)

Signed-off-by: Cunming Liang 
---
 v5 changes:
   add more comments for eal_parse_set
   fix some typo
   remove inline prefix from convert_to_cpuset()
   fix a bug introduced on v2 which broke case '(0,6)'

 v2 changes:
   add '-' support for EAL option '--lcores'

 lib/librte_eal/common/eal_common_options.c | 304 -
 lib/librte_eal/common/eal_options.h|   2 +
 lib/librte_eal/linuxapp/eal/Makefile   |   1 +
 3 files changed, 303 insertions(+), 4 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_options.c 
b/lib/librte_eal/common/eal_common_options.c
index 67e02dc..178e303 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -45,6 +45,7 @@
 #include 
 #include 
 #include 
+#include 

 #include "eal_internal_cfg.h"
 #include "eal_options.h"
@@ -85,6 +86,7 @@ eal_long_options[] = {
{OPT_XEN_DOM0, 0, 0, OPT_XEN_DOM0_NUM},
{OPT_CREATE_UIO_DEV, 1, NULL, OPT_CREATE_UIO_DEV_NUM},
{OPT_VFIO_INTR, 1, NULL, OPT_VFIO_INTR_NUM},
+   {OPT_LCORES, 1, 0, OPT_LCORES_NUM},
{0, 0, 0, 0}
 };

@@ -255,9 +257,11 @@ eal_parse_corelist(const char *corelist)
if (min == RTE_MAX_LCORE)
min = idx;
for (idx = min; idx <= max; idx++) {
-   cfg->lcore_role[idx] = ROLE_RTE;
-   lcore_config[idx].core_index = count;
-   count++;
+   if (cfg->lcore_role[idx] != ROLE_RTE) {
+   cfg->lcore_role[idx] = ROLE_RTE;
+   lcore_config[idx].core_index = count;
+   count++;
+   }
}
min = RTE_MAX_LCORE;
} else
@@ -292,6 +296,283 @@ eal_parse_master_lcore(const char *arg)
return 0;
 }

+/*
+ * Parse elem, the elem could be single number/range or '(' ')' group
+ * 1) A single number elem, it's just a simple digit. e.g. 9
+ * 2) A single range elem, two digits with a '-' between. e.g. 2-6
+ * 3) A group elem, combines multiple 1) or 2) with '( )'. e.g (0,2-4,6)
+ *Within group elem, '-' used for a range separator;
+ *   ',' used for a single number.
+ */
+static int
+eal_parse_set(const char *input, uint16_t set[], unsigned num)
+{
+   unsigned idx;
+   const char *str = input;
+   char *end = NULL;
+   unsigned min, max;
+
+   memset(set, 0, num * sizeof(uint16_t));
+
+   while (isblank(*str))
+   str++;
+
+   /* only digit or left bracket is qualify for start point */
+   if ((!isdigit(*str) && *str != '(') || *str == '\0')
+   return -1;
+
+   /* process single number or single range of number */
+   if (*str != '(') {
+   errno = 0;
+   idx = strtoul(str, , 10);
+   if (errno || end == NULL || idx >= num)
+   return -1;
+   else {
+   while (isblank(*end))
+   end++;
+
+   min = idx;
+   max = idx;
+   if (*end == '-') {
+   /* process single - */
+   end++;
+   while (isblank(*end))
+   end++;
+   if (!isdigit(*end))
+   return -1;
+
+   errno = 0;
+   idx = strtoul(end, , 10);
+   if (errno || end == NULL || idx >= num)
+   return -1;
+   max = idx;
+   while (isblank(*end))
+   end++;
+   if (*end != ',' && *end != '\0')
+   return -1;
+   }
+
+   if (*end != ',' && *end != '\0' &&
+   *end != '@')
+   return -1;
+
+   for (idx = 

[dpdk-dev] [PATCH v5 02/19] eal: fix PAGE_SIZE redefine complaint on freebsd

2015-02-12 Thread Cunming Liang

Signed-off-by: Cunming Liang 
---
 lib/librte_eal/bsdapp/eal/eal_memory.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lib/librte_eal/bsdapp/eal/eal_memory.c 
b/lib/librte_eal/bsdapp/eal/eal_memory.c
index 65ee87d..33ebd0f 100644
--- a/lib/librte_eal/bsdapp/eal/eal_memory.c
+++ b/lib/librte_eal/bsdapp/eal/eal_memory.c
@@ -45,7 +45,7 @@
 #include "eal_internal_cfg.h"
 #include "eal_filesystem.h"

-#define PAGE_SIZE (sysconf(_SC_PAGESIZE))
+#define EAL_PAGE_SIZE (sysconf(_SC_PAGESIZE))

 /*
  * Get physical address of any mapped virtual address in the current process.
@@ -93,7 +93,8 @@ rte_eal_contigmem_init(void)
char physaddr_str[64];

addr = mmap(NULL, hpi->hugepage_sz, 
PROT_READ|PROT_WRITE,
-   MAP_SHARED, hpi->lock_descriptor, j * 
PAGE_SIZE);
+   MAP_SHARED, hpi->lock_descriptor,
+   j * EAL_PAGE_SIZE);
if (addr == MAP_FAILED) {
RTE_LOG(ERR, EAL, "Failed to mmap buffer %u 
from %s\n",
j, hpi->hugedir);
@@ -167,7 +168,8 @@ rte_eal_contigmem_attach(void)
struct rte_memseg *seg = >memseg[i];

addr = mmap(seg->addr, hpi->hugepage_sz, PROT_READ|PROT_WRITE,
-   MAP_SHARED|MAP_FIXED, fd_hugepage, i * 
PAGE_SIZE);
+   MAP_SHARED|MAP_FIXED, fd_hugepage,
+   i * EAL_PAGE_SIZE);
if (addr == MAP_FAILED || addr != seg->addr) {
RTE_LOG(ERR, EAL, "Failed to mmap buffer %u from %s\n",
i, hpi->hugedir);
-- 
1.8.1.4



[dpdk-dev] [PATCH v5 01/19] eal: add cpuset into per EAL thread lcore_config

2015-02-12 Thread Cunming Liang
The patch adds 'cpuset' into per-lcore configure 'lcore_config[]',
as the lcore no longer always 1:1 pinning with physical cpu.
The lcore now stands for a EAL thread rather than a logical cpu.

It doesn't change the default behavior of 1:1 mapping, but allows to
affinity the EAL thread to multiple cpus.

Signed-off-by: Cunming Liang 
---
 v5 changes:
   separate eal_memory.c to the new patch

 lib/librte_eal/bsdapp/eal/eal_lcore.c | 7 +++
 lib/librte_eal/common/include/rte_lcore.h | 8 
 lib/librte_eal/linuxapp/eal/Makefile  | 1 +
 lib/librte_eal/linuxapp/eal/eal_lcore.c   | 8 
 4 files changed, 24 insertions(+)

diff --git a/lib/librte_eal/bsdapp/eal/eal_lcore.c 
b/lib/librte_eal/bsdapp/eal/eal_lcore.c
index 662f024..72f8ac2 100644
--- a/lib/librte_eal/bsdapp/eal/eal_lcore.c
+++ b/lib/librte_eal/bsdapp/eal/eal_lcore.c
@@ -76,11 +76,18 @@ rte_eal_cpu_init(void)
 * ones and enable them by default.
 */
for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
+   /* init cpuset for per lcore config */
+   CPU_ZERO(_config[lcore_id].cpuset);
+
lcore_config[lcore_id].detected = (lcore_id < ncpus);
if (lcore_config[lcore_id].detected == 0) {
config->lcore_role[lcore_id] = ROLE_OFF;
continue;
}
+
+   /* By default, lcore 1:1 map to cpu id */
+   CPU_SET(lcore_id, _config[lcore_id].cpuset);
+
/* By default, each detected core is enabled */
config->lcore_role[lcore_id] = ROLE_RTE;
lcore_config[lcore_id].core_id = cpu_core_id(lcore_id);
diff --git a/lib/librte_eal/common/include/rte_lcore.h 
b/lib/librte_eal/common/include/rte_lcore.h
index 49b2c03..4c7d6bb 100644
--- a/lib/librte_eal/common/include/rte_lcore.h
+++ b/lib/librte_eal/common/include/rte_lcore.h
@@ -50,6 +50,13 @@ extern "C" {

 #define LCORE_ID_ANY -1/**< Any lcore. */

+#if defined(__linux__)
+   typedef cpu_set_t rte_cpuset_t;
+#elif defined(__FreeBSD__)
+#include 
+   typedef cpuset_t rte_cpuset_t;
+#endif
+
 /**
  * Structure storing internal configuration (per-lcore)
  */
@@ -65,6 +72,7 @@ struct lcore_config {
unsigned socket_id;/**< physical socket id for this lcore */
unsigned core_id;  /**< core number on socket for this lcore */
int core_index;/**< relative index, starting from 0 */
+   rte_cpuset_t cpuset;   /**< cpu set which the lcore affinity to */
 };

 /**
diff --git a/lib/librte_eal/linuxapp/eal/Makefile 
b/lib/librte_eal/linuxapp/eal/Makefile
index e117cec..1b6c484 100644
--- a/lib/librte_eal/linuxapp/eal/Makefile
+++ b/lib/librte_eal/linuxapp/eal/Makefile
@@ -91,6 +91,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_dev.c
 SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_options.c

 CFLAGS_eal.o := -D_GNU_SOURCE
+CFLAGS_eal_lcore.o := -D_GNU_SOURCE
 CFLAGS_eal_thread.o := -D_GNU_SOURCE
 CFLAGS_eal_log.o := -D_GNU_SOURCE
 CFLAGS_eal_common_log.o := -D_GNU_SOURCE
diff --git a/lib/librte_eal/linuxapp/eal/eal_lcore.c 
b/lib/librte_eal/linuxapp/eal/eal_lcore.c
index c67e0e6..29615f8 100644
--- a/lib/librte_eal/linuxapp/eal/eal_lcore.c
+++ b/lib/librte_eal/linuxapp/eal/eal_lcore.c
@@ -158,11 +158,19 @@ rte_eal_cpu_init(void)
 * ones and enable them by default.
 */
for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
+   /* init cpuset for per lcore config */
+   CPU_ZERO(_config[lcore_id].cpuset);
+
+   /* in 1:1 mapping, record related cpu detected state */
lcore_config[lcore_id].detected = cpu_detected(lcore_id);
if (lcore_config[lcore_id].detected == 0) {
config->lcore_role[lcore_id] = ROLE_OFF;
continue;
}
+
+   /* By default, lcore 1:1 map to cpu id */
+   CPU_SET(lcore_id, _config[lcore_id].cpuset);
+
/* By default, each detected core is enabled */
config->lcore_role[lcore_id] = ROLE_RTE;
lcore_config[lcore_id].core_id = cpu_core_id(lcore_id);
-- 
1.8.1.4



[dpdk-dev] [PATCH v5 00/19] support multi-pthread per core

2015-02-12 Thread Cunming Liang
v5 changes:
  reorder some patch and split into addtional two patches
  rte_thread_get_affinity() return type change to avoid
  add RTE_RING_PAUSE_REP into config and by default turn off

v4 changes:
  new patch fixing strnlen() invalid return in 32bit icc [03/17]
  update and add more comments on sched_yield() [16/17]

v3 changes:
  new patch adding sched_yield() in rte_ring to avoid long spin [16/17]

v2 changes:
  add '-' support for EAL option '--lcores' [02/17]

The patch series contain the enhancements of EAL and fixes for libraries
to run multi-pthreads(either EAL or non-EAL thread) per physical core.
Two major changes list as below:
- Extend the core affinity of each EAL thread to 1:n.
  Each lcore stands for a EAL thread rather than a logical core.
  The change adds new EAL option to allow static lcore to cpuset assginment.
  Then a lcore(EAL thread) affinity to a cpuset, original 1:1 mapping is the 
special case.
- Fix the libraries to allow running on any non-EAL thread.
  It fix the gaps running libraries in non-EAL thread(dynamic created by user).
  Each fix libraries take care the case of rte_lcore_id() >= RTE_MAX_LCORE.

Thanks a million for the comments from Konstantin, Bruce, Mirek and Stephen in 
RFC review.

*** BLURB HERE ***

Cunming Liang (19):
  eal: add cpuset into per EAL thread lcore_config
  eal: fix PAGE_SIZE redefine complaint on freebsd
  eal: new eal option '--lcores' for cpu assignment
  eal: fix wrong strnlen() return value in 32bit icc
  eal: add support parsing socket_id from cpuset
  eal: new TLS definition and API declaration
  eal: add eal_common_thread.c for common thread API
  eal: standardize init sequence between linux and bsd
  eal: add rte_gettid() to acquire unique system tid
  eal: apply affinity of EAL thread by assigned cpuset
  enic: fix re-define freebsd compile complain
  malloc: fix the issue of SOCKET_ID_ANY
  log: fix the gap to support non-EAL thread
  eal: set _lcore_id and _socket_id to (-1) by default
  eal: fix recursive spinlock in non-EAL thraed
  mempool: add support to non-EAL thread
  ring: add support to non-EAL thread
  ring: add sched_yield to avoid spin forever
  timer: add support to non-EAL thread

 config/common_bsdapp   |   1 +
 config/common_linuxapp |   1 +
 lib/librte_eal/bsdapp/eal/Makefile |   1 +
 lib/librte_eal/bsdapp/eal/eal.c|  14 +-
 lib/librte_eal/bsdapp/eal/eal_lcore.c  |  14 +
 lib/librte_eal/bsdapp/eal/eal_memory.c |   8 +-
 lib/librte_eal/bsdapp/eal/eal_thread.c |  77 ++
 lib/librte_eal/common/eal_common_log.c |  17 +-
 lib/librte_eal/common/eal_common_options.c | 308 -
 lib/librte_eal/common/eal_common_thread.c  | 150 ++
 lib/librte_eal/common/eal_options.h|   2 +
 lib/librte_eal/common/eal_thread.h |  47 
 .../common/include/generic/rte_spinlock.h  |   4 +-
 lib/librte_eal/common/include/rte_eal.h|  27 ++
 lib/librte_eal/common/include/rte_lcore.h  |  40 ++-
 lib/librte_eal/common/include/rte_log.h|   5 +
 lib/librte_eal/linuxapp/eal/Makefile   |   4 +
 lib/librte_eal/linuxapp/eal/eal.c  |   8 +-
 lib/librte_eal/linuxapp/eal/eal_lcore.c|  15 +-
 lib/librte_eal/linuxapp/eal/eal_thread.c   |  77 ++
 lib/librte_malloc/malloc_heap.h|   7 +-
 lib/librte_mempool/rte_mempool.h   |  18 +-
 lib/librte_pmd_enic/enic.h |   4 +-
 lib/librte_pmd_enic/enic_compat.h  |   2 +-
 lib/librte_pmd_enic/vnic/vnic_dev.c|   6 +-
 lib/librte_ring/rte_ring.h |  41 ++-
 lib/librte_timer/rte_timer.c   |  31 ++-
 lib/librte_timer/rte_timer.h   |   4 +-
 28 files changed, 764 insertions(+), 169 deletions(-)
 create mode 100644 lib/librte_eal/common/eal_common_thread.c

-- 
1.8.1.4



[dpdk-dev] [PATCH] eal: add rte_eal_iopl_init to version map

2015-02-12 Thread Thomas Monjalon
2015-02-11 13:30, Sergio Gonzalez Monroy:
> Common rte_eal_iopl_init function is missing from eal version map.

How did you see it?
Thanks

>   rte_eal_hpet_init;
> + rte_eal_iopl_init;
>   rte_eal_init;

You missed the alphabetical order, you were not so far ;)


[dpdk-dev] [PATCH 2/3] ethdev: Add in data rxtx callback support

2015-02-12 Thread Neil Horman
On Thu, Feb 12, 2015 at 07:57:56PM +, John McNamara wrote:
> From: Richardson, Bruce 
> 
> Add in support for inline processing of packets inside the RX or
> TX call. For an RX callback, what happens is that we get a set of
> packets from the NIC and then pass them to a callback function, if
> configured, to allow additional processing to be done on them, e.g.
> filling in more mbuf fields, before passing back to the application.
> On TX, the packets are similarly post-processed before being handed
> to the NIC for transmission.
> 
> Signed-off-by: Bruce Richardson 
> ---
>  lib/librte_ether/rte_ethdev.c |  165 +-
>  lib/librte_ether/rte_ethdev.h |  175 
> -
>  2 files changed, 334 insertions(+), 6 deletions(-)
> 
> diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
> index e4b3315..944737e 100644
> --- a/lib/librte_ether/rte_ethdev.c
> +++ b/lib/librte_ether/rte_ethdev.c
> @@ -337,6 +337,15 @@ rte_eth_dev_rx_queue_config(struct rte_eth_dev *dev, 
> uint16_t nb_queues)
>   dev->data->nb_rx_queues = 0;
>   return -(ENOMEM);
>   }
> + dev->rx_cbs = rte_zmalloc("ethdev->rx_cbs",
> + sizeof(*dev->rx_cbs) * nb_queues,
> + RTE_CACHE_LINE_SIZE);
> + if (dev->rx_cbs == NULL) {
> + rte_free(dev->data->rx_queues);
> + dev->data->rx_queues = NULL;
> + dev->data->nb_rx_queues = 0;
> + return -(ENOMEM);
> + }
>   } else { /* re-configure */
>   FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_release, -ENOTSUP);
>  
> @@ -348,10 +357,18 @@ rte_eth_dev_rx_queue_config(struct rte_eth_dev *dev, 
> uint16_t nb_queues)
>   RTE_CACHE_LINE_SIZE);
>   if (rxq == NULL)
>   return -(ENOMEM);
> + dev->rx_cbs = rte_realloc(dev->rx_cbs, sizeof(*dev->rx_cbs) *
> + nb_queues, RTE_CACHE_LINE_SIZE);
> + if (dev->rx_cbs == NULL)
> + return -(ENOMEM);
>  
> - if (nb_queues > old_nb_queues)
> + if (nb_queues > old_nb_queues) {
> + uint16_t new_qs = nb_queues - old_nb_queues;
>   memset(rxq + old_nb_queues, 0,
> - sizeof(rxq[0]) * (nb_queues - old_nb_queues));
> + sizeof(rxq[0]) * new_qs);
> + memset(dev->rx_cbs + old_nb_queues, 0,
> + sizeof(dev->rx_cbs[0]) * new_qs);
> + }
>  
>   dev->data->rx_queues = rxq;
>  
> @@ -479,6 +496,15 @@ rte_eth_dev_tx_queue_config(struct rte_eth_dev *dev, 
> uint16_t nb_queues)
>   dev->data->nb_tx_queues = 0;
>   return -(ENOMEM);
>   }
> + dev->tx_cbs = rte_zmalloc("ethdev->tx_cbs",
> + sizeof(*dev->tx_cbs) * nb_queues,
> + RTE_CACHE_LINE_SIZE);
> + if (dev->tx_cbs == NULL) {
> + rte_free(dev->data->tx_queues);
> + dev->data->tx_queues = NULL;
> + dev->data->nb_tx_queues = 0;
> + return -(ENOMEM);
> + }
>   } else { /* re-configure */
>   FUNC_PTR_OR_ERR_RET(*dev->dev_ops->tx_queue_release, -ENOTSUP);
>  
> @@ -490,10 +516,19 @@ rte_eth_dev_tx_queue_config(struct rte_eth_dev *dev, 
> uint16_t nb_queues)
>   RTE_CACHE_LINE_SIZE);
>   if (txq == NULL)
>   return -(ENOMEM);
> + dev->tx_cbs = rte_realloc(dev->tx_cbs, sizeof(*dev->tx_cbs) *
> + nb_queues, RTE_CACHE_LINE_SIZE);
> + if (dev->tx_cbs == NULL)
> + return -(ENOMEM);
> +
>  
> - if (nb_queues > old_nb_queues)
> + if (nb_queues > old_nb_queues) {
> + uint16_t new_qs = nb_queues - old_nb_queues;
>   memset(txq + old_nb_queues, 0,
> - sizeof(txq[0]) * (nb_queues - old_nb_queues));
> + sizeof(txq[0]) * new_qs);
> + memset(dev->tx_cbs + old_nb_queues, 0,
> + sizeof(dev->tx_cbs[0]) * new_qs);
> + }
>  
>   dev->data->tx_queues = txq;
>  
> @@ -3253,3 +3288,125 @@ rte_eth_dev_filter_ctrl(uint8_t port_id, enum 
> rte_filter_type filter_type,
>   FUNC_PTR_OR_ERR_RET(*dev->dev_ops->filter_ctrl, -ENOTSUP);
>   return (*dev->dev_ops->filter_ctrl)(dev, filter_type, filter_op, arg);
>  }
> +
> +void *
> +rte_eth_add_rx_callback(uint8_t port_id, uint16_t queue_id,
> + rte_rxtx_callback_fn fn, void *user_param)
> +{
These, and its companion 

[dpdk-dev] [PATCH 0/8] Improve build process

2015-02-12 Thread Panu Matilainen
On 02/12/2015 02:23 PM, Neil Horman wrote:
> On Thu, Feb 12, 2015 at 10:03:51AM +, Gonzalez Monroy, Sergio wrote:
>> On 12/02/2015 09:22, Panu Matilainen wrote:
>>> On 02/11/2015 01:11 PM, Gonzalez Monroy, Sergio wrote:
> From: Neil Horman [mailto:nhorman at tuxdriver.com]
> Sent: Friday, January 30, 2015 6:13 PM
> To: Gonzalez Monroy, Sergio
> Cc: Thomas Monjalon; dev at dpdk.org
> Subject: Re: [dpdk-dev] [PATCH 0/8] Improve build process
>
> On Fri, Jan 30, 2015 at 05:38:49PM +, Gonzalez Monroy, Sergio
> wrote:

 [snip]

>>
>> So would it be reasonable to add DT_NEEDED entries to all DPDK
>> libraries
> but EAL?
>> If I understood what you were saying right, we could enforce the
>> 'dependency' in the linker script with something like this:
>> $ cat  librte_eal.so
>> INPUT( librte_eal.so.1 -lrte_mempool -lrte_malloc) We could have such
>> linker script for librte_eal.so instead of the soft link once
>> versioning is in place.
>>
> Correct.
>
>> Things that would be missing versus the proposed patch:
>>   - As I have mention in previous post, ldd info for EAL library
>> would not
> reflect
>> its dependency to other DPDK libs.
> librte_eal.so would no show those dependencies, as far as I know
> (though I
> haven't explicitly checked).  The subordunate libraries included in
> the input
> line, may or may not show dependencies among themselves, depending on
> your build setup (and the use of --no-as-needed and -l when linking the
> individual .so libraries.
>
>>   - I was enforcing resolving all references when building the
>> libraries (-z
> defs), so
>> we either remove it altogether or skip eal.
> I think thats correct, yes.
>
>>   - All apps would show DT_NEEDED entries for a set of DPDK
>> libraries that
>> in most cases are required (eal, mempool, malloc, mbuf, ring VS
>> dpdk_core)
>>
> I think apps linked to libdpdk_core would have DT_NEEDED entries for
> libdpdk_core, not the subordonate libraries (though check me on that
> to be
> sure).
>
 Just checked on this and they do link against the subordinate libraries,
 although
 It does not really matter as we are dropping the 'core' library approach
 anyway.

>> I think that the linker script approach is reasonable if we prefer to
>> go that way instead of creating a core library.
>>
> I think it would make sense from a build environment point of view, in
> that it
> allows library specific flags to be incorporated properly.  I think
> the only
> downside is that the individual libraries still need to be carried
> around
> (though they can be ignored from an application build/run standpoint).
> You're question should probably be asked of people using COMBINED_LIBS
> currently to make sure that meets their needs, though I think it will.
>
> Neil
>
 So I just realized that I was not having into account a possible
 scenario, where
 we have an app built with static dpdk libs then loading a dso with -d
 option.

 In such case, because the pmd would have DT_NEEDED entries, dlopen will
 fail.
 So to enable such scenario we would need to build PMDs without DT_NEEDED
 entries.
>>>
>>> Hmm, for that to be a problem you'd need to have the PMD built against
>>> shared dpdk libs and while the application is built against static dpdk
>>> libs. I dont think that's a supportable scenario in any case.
>>>
>>> Or is there some other scenario that I'm not seeing?
>>>
>>> - Panu -
>>>
>> I agree with you. I suppose it comes down to, do we want to support such
>> scenario?
>>
>>  From what I can see, it seems that we do currently support such scenario by
>> building dpdk apps against all static dpdk libs using --whole-archive (all
>> libs and not only PMDs).
>> http://dpdk.org/browse/dpdk/commit/?id=20afd76a504155e947c770783ef5023e87136ad8
>>
>> Am I misunderstanding this?
>>
> Shoot, you're right, I missed the static build aspect to this.  Yes, if we do 
> the following:
>
> 1) Build the DPDK as a static library
> 2) Link an application against (1)
> 3) Use the dlopen mechanism to load a PMD built as a DSO
>
> Then the DT_NEEDED entries in the DSO will go unsatisfied, because the shared
> objects on which it (the PMD) depends will not exist in the file system.

I think its even more twisty:

1) Build the DPDK as a static library
2) Link an application against (1)
3) Do another build of DPDK as a shared library
4) In app 2), use the dlopen mechanism to load a PMD built as a part of 
or against 3)

Somehow I doubt this would work very well.

>
> I think the problem is a little bit orthogonal to the libdpdk_core problem you
> were initially addressing.  That is to say, this problem of dlopen-ed PMD's
> exists regardless of 

[dpdk-dev] [PATCH] Make -Werror optional

2015-02-12 Thread Panu Matilainen
On 02/12/2015 02:08 PM, Bruce Richardson wrote:
> On Thu, Feb 12, 2015 at 02:02:19PM +0200, Panu Matilainen wrote:
>> On 02/12/2015 01:25 PM, Bruce Richardson wrote:
>>> On Thu, Feb 12, 2015 at 01:13:22PM +0200, Panu Matilainen wrote:
 This adds new CONFIG_RTE_ERROR_ON_WARNING config option to enable
 fail-on-warning compile behavior, defaulting to off.

 Failing build on warnings is a useful developer tool but its bad
 for release tarballs which can and do get built with newer
 compilers than what was used/available during development. Compilers
 routinely add new warnings so code which built silently with cc X
 might no longer do so with X+1. This doesn't make the existing code
 any more buggier and failing the build in this case does not help
 not help improve code quality of an already released version either.
>>>
>>> This can already be achieve by passing EXTRA_CFLAGS='-Wno-error' into the
>>> build command. I don't like changing the default option here. Better to
>>> instead document how to disable the warning flags if necessary.
>>
>> Well, optimally it would only default to off in released versions, which is
>> where the Werror behavior is just annoying without being useful.
>
> This I can agree with.

Ok, would something to this tune be more acceptable?

diff --git a/mk/rte.vars.mk b/mk/rte.vars.mk
index d5b36be..2ad969b 100644
--- a/mk/rte.vars.mk
+++ b/mk/rte.vars.mk
@@ -71,6 +71,10 @@ ifneq ($(BUILDING_RTE_SDK),)
ifeq ($(RTE_BUILD_COMBINE_LIBS),)
  RTE_BUILD_COMBINE_LIBS := n
endif
+  # see if we're building from git
+  ifneq ($(wildcard $(RTE_SDK)/.git),)
+DEVEL_BUILD := y
+  endif
  endif

  RTE_LIBNAME := $(CONFIG_RTE_LIBNAME:"%"=%)
diff --git a/mk/toolchain/gcc/rte.vars.mk b/mk/toolchain/gcc/rte.vars.mk
index 88f235c..a14ae44 100644
--- a/mk/toolchain/gcc/rte.vars.mk
+++ b/mk/toolchain/gcc/rte.vars.mk
@@ -71,12 +71,16 @@ ifeq (,$(findstring -O0,$(EXTRA_CFLAGS)))
  endif
  endif

-WERROR_FLAGS := -W -Wall -Werror -Wstrict-prototypes -Wmissing-prototypes
+WERROR_FLAGS := -W -Wall -Wstrict-prototypes -Wmissing-prototypes
  WERROR_FLAGS += -Wmissing-declarations -Wold-style-definition 
-Wpointer-arith
  WERROR_FLAGS += -Wcast-align -Wnested-externs -Wcast-qual
  WERROR_FLAGS += -Wformat-nonliteral -Wformat-security
  WERROR_FLAGS += -Wundef -Wwrite-strings

+ifeq ($(DEVEL_BUILD),y)
+WERROR_FLAGS += -Werror
+endif
+
  # process cpu flags
  include $(RTE_SDK)/mk/toolchain/$(RTE_TOOLCHAIN)/rte.toolchain-compat.mk

(non-gcc toolchains are missing and whitespace probably broken due to 
copy-paste, this is not a suggested patch but just an RFC for the approach)


- Panu -



[dpdk-dev] [PATCH 0/4] Broadcom 10G NIC Poll Mode Driver

2015-02-12 Thread Thomas Monjalon
2015-02-12 06:33, Stephen Hemminger:
> On Thu, 12 Feb 2015 15:00:13 +0100
> Thomas Monjalon  wrote:
> 
> > Hi Stephen,
> > 
> > 2015-02-07 07:15, Stephen Hemminger:
> > > Source was from FreeBSD.
> > > 
> > > changes were to make it work and lots of de-uglification.
> > 
> > Maintenance would be eased by showing this work with separate commits.
> > You should at least have a patch for importing FreeBSD source without
> > modifications.
> > 
> > Other comment: there could be other drivers for Broadcom devices.
> > Why not keeping the name bnx2x?
> > 
> > Thanks
> 
> That history is lost.

I don't understand your answer,
and you forgot one question.
Please reply below each question.

I said: "You should at least have a patch for importing FreeBSD source
without modfications". Is the initial FreeBSD source lost?

Do you agree to rename to bnx2x?


[dpdk-dev] [PATCH] eal: add rte_eal_iopl_init to version map

2015-02-12 Thread Gonzalez Monroy, Sergio
On 12/02/2015 15:39, Sergio Gonzalez Monroy wrote:
> Building shared libraries and using virtio PMD results in undefined
> reference to 'rte_eal_iopl_init'.
>
> Add missing function to eal version map.
>
> Signed-off-by: Sergio Gonzalez Monroy 
> ---
>   lib/librte_eal/bsdapp/eal/rte_eal_version.map   | 1 +
>   lib/librte_eal/linuxapp/eal/rte_eal_version.map | 1 +
>   2 files changed, 2 insertions(+)
>
Self-NACK missing v2 details.


[dpdk-dev] [PATCH] eal: fix fscanf format mismatch

2015-02-12 Thread Sergio Gonzalez Monroy
Variables are unsigned int but format scans for signed int.

Signed-off-by: Sergio Gonzalez Monroy 
---
 lib/librte_eal/linuxapp/eal/eal_pci_uio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c 
b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
index e53f06b..54cce08 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
@@ -176,7 +176,7 @@ pci_mknod_uio_dev(const char *sysfs_uio_path, unsigned 
uio_num)
return -1;
}

-   ret = fscanf(f, "%d:%d", , );
+   ret = fscanf(f, "%u:%u", , );
if (ret != 2) {
RTE_LOG(ERR, EAL, "%s(): cannot parse sysfs to get 
major:minor\n",
__func__);
-- 
1.9.3



[dpdk-dev] [PATCH] eal: add rte_eal_iopl_init to version map

2015-02-12 Thread Sergio Gonzalez Monroy
Building shared libraries and using virtio PMD results in undefined
reference to 'rte_eal_iopl_init'.

Add missing function to eal version map.

Signed-off-by: Sergio Gonzalez Monroy 
---
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   | 1 +
 lib/librte_eal/linuxapp/eal/rte_eal_version.map | 1 +
 2 files changed, 2 insertions(+)

diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map 
b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
index d36286e..5ed6e4d 100644
--- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
@@ -33,6 +33,7 @@ DPDK_2.0 {
rte_eal_has_hugepages;
rte_eal_hpet_init;
rte_eal_init;
+   rte_eal_iopl_init;
rte_eal_lcore_role;
rte_eal_mp_remote_launch;
rte_eal_mp_wait_lcore;
diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map 
b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
index d36286e..5ed6e4d 100644
--- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
@@ -33,6 +33,7 @@ DPDK_2.0 {
rte_eal_has_hugepages;
rte_eal_hpet_init;
rte_eal_init;
+   rte_eal_iopl_init;
rte_eal_lcore_role;
rte_eal_mp_remote_launch;
rte_eal_mp_wait_lcore;
-- 
1.9.3



[dpdk-dev] [PATCH] eal: add rte_eal_iopl_init to version map

2015-02-12 Thread Gonzalez Monroy, Sergio
On 12/02/2015 15:12, Thomas Monjalon wrote:
> 2015-02-11 13:30, Sergio Gonzalez Monroy:
>> Common rte_eal_iopl_init function is missing from eal version map.
> How did you see it?
> Thanks
Building shared libraries and using virtio PMD would result in undefined 
reference symbol.
Should I add it to the commit log?
>>  rte_eal_hpet_init;
>> +rte_eal_iopl_init;
>>  rte_eal_init;
> You missed the alphabetical order, you were not so far ;)
Oh, I did not realize it was alphabetical order, I'll send v2.

Regards,
Sergio


[dpdk-dev] Packet drops during non-exhaustive flood with OVS and 1.8.0

2015-02-12 Thread Traynor, Kevin
> -Original Message-
> From: Andrey Korolyov [mailto:andrey at xdel.ru]
> Sent: Tuesday, February 3, 2015 5:21 PM
> To: Traynor, Kevin
> Cc: dev at dpdk.org; discuss at openvswitch.org
> Subject: Re: Packet drops during non-exhaustive flood with OVS and 1.8.0
> 
> > These patches are to enable DPDK 1.8 only. What 'bulk processing' are you 
> > referring to?
> > By default there is a batch size of 192 in netdev-dpdk for rx from the NIC 
> > - the linked
> > patch doesn't change this, just the DPDK version.
> 
> Sorry, I referred the wrong part there: bulk transmission, which is
> clearly not involved in my case. The idea was that the conditionally
> enabling prefetch for rx queues (BULK_ALLOC) may help somehow, but
> it`s probably will mask issue instead of solving it directly. By my
> understanding, strict drop rule should have a zero impact on a main
> ovs thread (and this is true) and work just fine with a line rate
> (this is not).

I've set a similar drop rule and I'm seeing the first packet drops occurring 
at 13.9 mpps for 64 byte pkts. I'm not sure if there is a config that can be 
changed or if it just the cost of the emc/lookups

> 
> >
> > Main things to consider are to isocpu's, pin the pmd thread and keep 
> > everything
> > on 1 NUMA socket. At 11 mpps without packet loss on that processor I 
> > suspect you are
> > doing those things already.
> 
> Yes, with all tuning improvements I was able to do this, but bare
> Linux stack on same machine is able to handle 12Mpps and there are
> absolutely no hints of what exactly is being congested.


[dpdk-dev] [PATCH] Make -Werror optional

2015-02-12 Thread Thomas Monjalon
2015-02-12 15:58, Panu Matilainen:
> +  # see if we're building from git
> +  ifneq ($(wildcard $(RTE_SDK)/.git),)
> +DEVEL_BUILD := y
> +  endif

Yes it allows to force DEVEL_BUILD to any value on command line.
But please use RTE_ prefix.


[dpdk-dev] [PATCH 0/4] Broadcom 10G NIC Poll Mode Driver

2015-02-12 Thread Thomas Monjalon
Hi Stephen,

2015-02-07 07:15, Stephen Hemminger:
> Source was from FreeBSD.
> 
> changes were to make it work and lots of de-uglification.

Maintenance would be eased by showing this work with separate commits.
You should at least have a patch for importing FreeBSD source without
modifications.

Other comment: there could be other drivers for Broadcom devices.
Why not keeping the name bnx2x?

Thanks


[dpdk-dev] [PATCH] testpmd: use default rx/tx port configuration values

2015-02-12 Thread Pablo de Lara
Function to get rx/tx port configuration from the PMDs
was added in previous release to simplify the port configuration
in all sample apps, but testpmd was not modified.

This patch makes testpmd get the default rx/tx port configuration,
but still uses the parameters passed by the command line.

This patch depends on patch "testpmd: remove duplicated parameter parsing"
(http://dpdk.org/dev/patchwork/patch/3015)

Signed-off-by: Pablo de Lara 
---
 app/test-pmd/cmdline.c|   12 +++---
 app/test-pmd/config.c |   15 +--
 app/test-pmd/parameters.c |   20 +-
 app/test-pmd/testpmd.c|   93 +++--
 app/test-pmd/testpmd.h|   18 +---
 5 files changed, 93 insertions(+), 65 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 590e427..a310680 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -2097,17 +2097,17 @@ cmd_config_thresh_parsed(void *parsed_result,
}

if (!strcmp(res->name, "txpt"))
-   tx_thresh.pthresh = res->value;
+   tx_pthresh = res->value;
else if(!strcmp(res->name, "txht"))
-   tx_thresh.hthresh = res->value;
+   tx_hthresh = res->value;
else if(!strcmp(res->name, "txwt"))
-   tx_thresh.wthresh = res->value;
+   tx_wthresh = res->value;
else if(!strcmp(res->name, "rxpt"))
-   rx_thresh.pthresh = res->value;
+   rx_pthresh = res->value;
else if(!strcmp(res->name, "rxht"))
-   rx_thresh.hthresh = res->value;
+   rx_hthresh = res->value;
else if(!strcmp(res->name, "rxwt"))
-   rx_thresh.wthresh = res->value;
+   rx_wthresh = res->value;
else {
printf("Unknown parameter\n");
return;
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index c40f819..6bcd23c 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -774,18 +774,23 @@ rxtx_config_display(void)
printf("  packet len=%u - nb packet segments=%d\n",
(unsigned)tx_pkt_length, (int) tx_pkt_nb_segs);

+   struct rte_eth_rxconf *rx_conf = [0].rx_conf;
+   struct rte_eth_txconf *tx_conf = [0].tx_conf;
+
printf("  nb forwarding cores=%d - nb forwarding ports=%d\n",
   nb_fwd_lcores, nb_fwd_ports);
printf("  RX queues=%d - RX desc=%d - RX free threshold=%d\n",
-  nb_rxq, nb_rxd, rx_free_thresh);
+  nb_rxq, nb_rxd, rx_conf->rx_free_thresh);
printf("  RX threshold registers: pthresh=%d hthresh=%d wthresh=%d\n",
-  rx_thresh.pthresh, rx_thresh.hthresh, rx_thresh.wthresh);
+  rx_conf->rx_thresh.pthresh, rx_conf->rx_thresh.hthresh,
+  rx_conf->rx_thresh.wthresh);
printf("  TX queues=%d - TX desc=%d - TX free threshold=%d\n",
-  nb_txq, nb_txd, tx_free_thresh);
+  nb_txq, nb_txd, tx_conf->tx_free_thresh);
printf("  TX threshold registers: pthresh=%d hthresh=%d wthresh=%d\n",
-  tx_thresh.pthresh, tx_thresh.hthresh, tx_thresh.wthresh);
+  tx_conf->tx_thresh.pthresh, tx_conf->tx_thresh.hthresh,
+  tx_conf->tx_thresh.wthresh);
printf("  TX RS bit threshold=%d - TXQ flags=0x%"PRIx32"\n",
-  tx_rs_thresh, txq_flags);
+  tx_conf->tx_rs_thresh, tx_conf->txq_flags);
 }

 void
diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c
index e66153d..19fbf46 100644
--- a/app/test-pmd/parameters.c
+++ b/app/test-pmd/parameters.c
@@ -835,14 +835,14 @@ launch_args_parse(int argc, char** argv)
if (!strcmp(lgopts[opt_idx].name, "txfreet")) {
n = atoi(optarg);
if (n >= 0)
-   tx_free_thresh = (uint16_t)n;
+   tx_free_thresh = (int16_t)n;
else
rte_exit(EXIT_FAILURE, "txfreet must be 
>= 0\n");
}
if (!strcmp(lgopts[opt_idx].name, "txrst")) {
n = atoi(optarg);
if (n >= 0)
-   tx_rs_thresh = (uint16_t)n;
+   tx_rs_thresh = (int16_t)n;
else
rte_exit(EXIT_FAILURE, "txrst must be 
>= 0\n");
}
@@ -850,7 +850,7 @@ launch_args_parse(int argc, char** argv)
char *end = NULL;
n = strtoul(optarg, , 16);
if (n >= 0)
-   txq_flags = (uint32_t)n;
+   txq_flags = (int32_t)n;
  

[dpdk-dev] [PATCH] Make -Werror optional

2015-02-12 Thread Bruce Richardson
On Thu, Feb 12, 2015 at 03:58:07PM +0200, Panu Matilainen wrote:
> On 02/12/2015 02:08 PM, Bruce Richardson wrote:
> >On Thu, Feb 12, 2015 at 02:02:19PM +0200, Panu Matilainen wrote:
> >>On 02/12/2015 01:25 PM, Bruce Richardson wrote:
> >>>On Thu, Feb 12, 2015 at 01:13:22PM +0200, Panu Matilainen wrote:
> This adds new CONFIG_RTE_ERROR_ON_WARNING config option to enable
> fail-on-warning compile behavior, defaulting to off.
> 
> Failing build on warnings is a useful developer tool but its bad
> for release tarballs which can and do get built with newer
> compilers than what was used/available during development. Compilers
> routinely add new warnings so code which built silently with cc X
> might no longer do so with X+1. This doesn't make the existing code
> any more buggier and failing the build in this case does not help
> not help improve code quality of an already released version either.
> >>>
> >>>This can already be achieve by passing EXTRA_CFLAGS='-Wno-error' into the
> >>>build command. I don't like changing the default option here. Better to
> >>>instead document how to disable the warning flags if necessary.
> >>
> >>Well, optimally it would only default to off in released versions, which is
> >>where the Werror behavior is just annoying without being useful.
> >
> >This I can agree with.
> 
> Ok, would something to this tune be more acceptable?
> 
> diff --git a/mk/rte.vars.mk b/mk/rte.vars.mk
> index d5b36be..2ad969b 100644
> --- a/mk/rte.vars.mk
> +++ b/mk/rte.vars.mk
> @@ -71,6 +71,10 @@ ifneq ($(BUILDING_RTE_SDK),)
>ifeq ($(RTE_BUILD_COMBINE_LIBS),)
>  RTE_BUILD_COMBINE_LIBS := n
>endif
> +  # see if we're building from git
> +  ifneq ($(wildcard $(RTE_SDK)/.git),)
> +DEVEL_BUILD := y
> +  endif
>  endif
> 
>  RTE_LIBNAME := $(CONFIG_RTE_LIBNAME:"%"=%)
> diff --git a/mk/toolchain/gcc/rte.vars.mk b/mk/toolchain/gcc/rte.vars.mk
> index 88f235c..a14ae44 100644
> --- a/mk/toolchain/gcc/rte.vars.mk
> +++ b/mk/toolchain/gcc/rte.vars.mk
> @@ -71,12 +71,16 @@ ifeq (,$(findstring -O0,$(EXTRA_CFLAGS)))
>  endif
>  endif
> 
> -WERROR_FLAGS := -W -Wall -Werror -Wstrict-prototypes -Wmissing-prototypes
> +WERROR_FLAGS := -W -Wall -Wstrict-prototypes -Wmissing-prototypes
>  WERROR_FLAGS += -Wmissing-declarations -Wold-style-definition
> -Wpointer-arith
>  WERROR_FLAGS += -Wcast-align -Wnested-externs -Wcast-qual
>  WERROR_FLAGS += -Wformat-nonliteral -Wformat-security
>  WERROR_FLAGS += -Wundef -Wwrite-strings
> 
> +ifeq ($(DEVEL_BUILD),y)
> +WERROR_FLAGS += -Werror
> +endif
> +
>  # process cpu flags
>  include $(RTE_SDK)/mk/toolchain/$(RTE_TOOLCHAIN)/rte.toolchain-compat.mk
> 
> (non-gcc toolchains are missing and whitespace probably broken due to
> copy-paste, this is not a suggested patch but just an RFC for the approach)
> 
> 
>   - Panu -
> 
Looks ok to me.
/Bruce


[dpdk-dev] [PATCH] Make -Werror optional

2015-02-12 Thread Panu Matilainen
On 02/12/2015 01:25 PM, Bruce Richardson wrote:
> On Thu, Feb 12, 2015 at 01:13:22PM +0200, Panu Matilainen wrote:
>> This adds new CONFIG_RTE_ERROR_ON_WARNING config option to enable
>> fail-on-warning compile behavior, defaulting to off.
>>
>> Failing build on warnings is a useful developer tool but its bad
>> for release tarballs which can and do get built with newer
>> compilers than what was used/available during development. Compilers
>> routinely add new warnings so code which built silently with cc X
>> might no longer do so with X+1. This doesn't make the existing code
>> any more buggier and failing the build in this case does not help
>> not help improve code quality of an already released version either.
>
> This can already be achieve by passing EXTRA_CFLAGS='-Wno-error' into the
> build command. I don't like changing the default option here. Better to
> instead document how to disable the warning flags if necessary.

Well, optimally it would only default to off in released versions, which 
is where the Werror behavior is just annoying without being useful.

For a practical example of how silly this can be: just got a build 
failure with 1.8 due to "variable set but not used" warnings, because 
gcc 5 is "smarter" and finds couple of cases older versions did not.
So everybody using gcc 5 to build the just-released 1.8 will be required 
to hunt down and pass in that extra disabler, for no good reason.

- Panu -



[dpdk-dev] [PATCH v7 04/14] eal/pci: Consolidate pci address comparison APIs

2015-02-12 Thread Iremonger, Bernard
> >  /* Scan one pci sysfs entry, and fill the devices list from
> > it. */ static int  pci_scan_one(const char *dirname, uint16_t
> > domain, uint8_t bus, @@ -353,13 +339,20 @@ pci_scan_one(const
> > char *dirname, uint16_t domain, uint8_t bus,
> > }
> > else {
> > struct rte_pci_device *dev2 = NULL;
> > +   int ret;
> >
> > TAILQ_FOREACH(dev2, _device_list, next) {
> > -   if (pci_addr_comparison(>addr, 
> > >addr))
> > +   ret = eal_compare_pci_addr(>addr, 
> > >addr);
> > +   if (ret > 0)
> > continue;
> > -   else {
> > +   else if (ret < 0) {
> > TAILQ_INSERT_BEFORE(dev2, dev, next);
> > return 0;
> > +   } else { /* already registered */
> > +   /* update pt_driver */
> > +   dev2->pt_driver = dev->pt_driver;
> >>> Hi Tetsuya,
> >>>
> >>> I am seeing a problem with the librte_pmd_ixgbe code where 
> >>> dev->max_vfs is being lost in
> some scenarios.
> >>> The following line should be added here:
> >>>   dev2->max_vfs = dev->max_vfs;
> >>>
> >>> numa_mode should probably be updated too (although it is not causing 
> >>> a problem at
> present).
> >>>   dev2->numa_mode = dev->numa_mode;

Hi Tetsuya, Michael,

The "already registered path" in the code is being executed.

dev->numa_mode does not change so the above line is not needed.

dev2->max_vfs has a value of 0  and dev->max_vfs has a value  of 2 ( 2 VF's 
have been configured previously).

dev2->mem_resource is different from dev->mem_resource so the following line 
needs to be added:

memmove(dev2->mem_resource, dev->mem_resource, sizeof(dev->mem_resource));

More replies below.

> >> I'm very curious, why those field miss? I haven't see any places
> >> clear this field.
> >>
> >> What is the root cause?

The max_vfs entry is created when igb_uio binds the device.
dev2  is the device already in the pci_device_list  so dev2->max_vfs  is 0.
dev is the new device being parsed, in this case dev->max_vfs is 2.
So the dev2->max_vfs  value needs to be updated.
Similarly  dev2-> pt_driver needs to be updated as its value is 0 (this is 
already done).
Similarly dev2->mem_resource needs to be updated as it is different from 
dev->mem_resource. 


> > Hi Michael,
> >
> > Here is my guess.
> > The above function creates pci device list.
>  I am sorry. I forgot to add below information.
> 
>  "max_vfs" or "numa_node" value is came from sysfs when the above
>  function is processed.
> >>> Yes, but it has already been registered, why it missed?
> >> Yes, it has been registered already, but probably should be updated.
> >> I guess sysfs value will be changed when igb_uio starts managing the 
> >> device.
> >>
> >> ex)
> >> 1. Boot linux
> >> 2. start a dpdk application with no port.
> >> 3. pci device list is registered.
> >>  - Here, "max_vfs" is came from sysfs. Or there is no such a entry.
> >> 4. igb_uio binds the device.
> >> 5.  I guess max_vfs value of sysfs is changed. Or max_vfs entry is created.
> >> 6. The dpdk application calls hotplug function.
> > Yes, agree.
> >
> > But numa node can be changed?
> 
> Hi Michael,
> 
> I may misunderstand meaning of numa_node.
> I thought it indicated which numa node was nearest from the pci device, so it 
> could not be
> configurable.
> BTW, I will be out of office tomorrow. So, I will submit v8 patches next 
> Monday.
> 
> Thanks,
> Tetsuya
> 
> >
> > Bernard, does your issue occur after max_vfs changed in igb_uio?
> >
> > If not, I think must be figure out the reason.
> >
> > Thanks,
> > Michael
> >>  - Here, I guess we need to update "max_vfs" value.
> >>
> >> Above is a just my assumption.
> >> It may be good to wait for Bernard's reply.
> >>
> >> Thanks,
> >> Tetsuya
> >>
> >>> Thanks,
> >>> Michael
> > And current DPDK implementation assumes all devices needed to be
> > managed are under igb_uio or vfio when above code is processed.
> > To add hotplug function, we also need to think some devices will
> > start to be managed under igb_uio or vfio after initializing pci device 
> > list.
> > Anyway, I guess "max_vfs" value will be changed when igb_uio or
> > vfio manages the device.
> >
> > Hi Bernard,
> >
> > Could you please check "max_vfs" and "num_node" values, then check
> > the values again after the device is managed by igb_uio or vfio?
> > In my environment, it seems max_vfs is created by igb_uio.

Yes, max_vfs is created by igb_uio

> > But my NIC doesn't have VF, so behavior might be different in your
> 

[dpdk-dev] [PATCH] x32 ABI support, first iteration

2015-02-12 Thread De Lara Guarch, Pablo


> -Original Message-
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Ananyev,
> Konstantin
> Sent: Monday, February 09, 2015 10:23 AM
> To: dev at dpdk.org
> Subject: Re: [dpdk-dev] [PATCH] x32 ABI support, first iteration
> 
> > Subject: [PATCH] x32 ABI support, first iteration
> >
> > Signed-off-by: Konstantin Ananyev 
> > Signed-off-by: Daniel Mrzyglod 
> > ---
> >  config/defconfig_x86_x32-native-linuxapp-gcc | 46
> 
> >  mk/arch/x86_x32/rte.vars.mk  | 63
> 
> >  2 files changed, 109 insertions(+)
> >  create mode 100644 config/defconfig_x86_x32-native-linuxapp-gcc
> >  create mode 100644 mk/arch/x86_x32/rte.vars.mk
> >
> > --
> 
> Acked-by: Konstantin Ananyev 
> 

Acked-by: Pablo de Lara 

Just add that documentation should be updated for this.
> > 1.9.1


[dpdk-dev] [PATCH] Make -Werror optional

2015-02-12 Thread Panu Matilainen
This adds new CONFIG_RTE_ERROR_ON_WARNING config option to enable
fail-on-warning compile behavior, defaulting to off.

Failing build on warnings is a useful developer tool but its bad
for release tarballs which can and do get built with newer
compilers than what was used/available during development. Compilers
routinely add new warnings so code which built silently with cc X
might no longer do so with X+1. This doesn't make the existing code
any more buggier and failing the build in this case does not help
not help improve code quality of an already released version either.
---
 config/common_bsdapp   | 1 +
 config/common_linuxapp | 1 +
 mk/toolchain/clang/rte.vars.mk | 5 -
 mk/toolchain/gcc/rte.vars.mk   | 5 -
 mk/toolchain/icc/rte.vars.mk   | 6 +-
 5 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/config/common_bsdapp b/config/common_bsdapp
index 57bacb8..a5687b3 100644
--- a/config/common_bsdapp
+++ b/config/common_bsdapp
@@ -362,6 +362,7 @@ CONFIG_RTE_KNI_VHOST_DEBUG_TX=n
 # Enable warning directives
 #
 CONFIG_RTE_INSECURE_FUNCTION_WARNING=n
+CONFIG_RTE_ERROR_ON_WARNING=n

 #
 # Compile the test application
diff --git a/config/common_linuxapp b/config/common_linuxapp
index d428f84..0762f99 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -383,6 +383,7 @@ CONFIG_RTE_LIBRTE_XEN_DOM0=n
 # Enable warning directives
 #
 CONFIG_RTE_INSECURE_FUNCTION_WARNING=n
+CONFIG_RTE_ERROR_ON_WARNING=n

 #
 # Compile the test application
diff --git a/mk/toolchain/clang/rte.vars.mk b/mk/toolchain/clang/rte.vars.mk
index 40cb389..12726e7 100644
--- a/mk/toolchain/clang/rte.vars.mk
+++ b/mk/toolchain/clang/rte.vars.mk
@@ -63,11 +63,14 @@ TOOLCHAIN_ASFLAGS =
 TOOLCHAIN_CFLAGS =
 TOOLCHAIN_LDFLAGS =

-WERROR_FLAGS := -W -Wall -Werror -Wstrict-prototypes -Wmissing-prototypes
+WERROR_FLAGS := -W -Wall -Wstrict-prototypes -Wmissing-prototypes
 WERROR_FLAGS += -Wmissing-declarations -Wold-style-definition -Wpointer-arith
 WERROR_FLAGS += -Wnested-externs -Wcast-qual
 WERROR_FLAGS += -Wformat-nonliteral -Wformat-security
 WERROR_FLAGS += -Wundef -Wwrite-strings
+ifeq ($(CONFIG_RTE_ERROR_ON_WARNING),y)
+WERROR_FLAGS += -Werror
+endif

 # process cpu flags
 include $(RTE_SDK)/mk/toolchain/$(RTE_TOOLCHAIN)/rte.toolchain-compat.mk
diff --git a/mk/toolchain/gcc/rte.vars.mk b/mk/toolchain/gcc/rte.vars.mk
index 88f235c..bbd3c85 100644
--- a/mk/toolchain/gcc/rte.vars.mk
+++ b/mk/toolchain/gcc/rte.vars.mk
@@ -71,11 +71,14 @@ ifeq (,$(findstring -O0,$(EXTRA_CFLAGS)))
 endif
 endif

-WERROR_FLAGS := -W -Wall -Werror -Wstrict-prototypes -Wmissing-prototypes
+WERROR_FLAGS := -W -Wall -Wstrict-prototypes -Wmissing-prototypes
 WERROR_FLAGS += -Wmissing-declarations -Wold-style-definition -Wpointer-arith
 WERROR_FLAGS += -Wcast-align -Wnested-externs -Wcast-qual
 WERROR_FLAGS += -Wformat-nonliteral -Wformat-security
 WERROR_FLAGS += -Wundef -Wwrite-strings
+ifeq ($(CONFIG_RTE_ERROR_ON_WARNING),y)
+WERROR_FLAGS += -Werror
+endif

 # process cpu flags
 include $(RTE_SDK)/mk/toolchain/$(RTE_TOOLCHAIN)/rte.toolchain-compat.mk
diff --git a/mk/toolchain/icc/rte.vars.mk b/mk/toolchain/icc/rte.vars.mk
index e39d710..652cca8 100644
--- a/mk/toolchain/icc/rte.vars.mk
+++ b/mk/toolchain/icc/rte.vars.mk
@@ -69,8 +69,12 @@ TOOLCHAIN_ASFLAGS =
 #   error #13368: loop was not vectorized with "vector always assert"
 #   error #15527: loop was not vectorized: function call to fprintf cannot be 
vectorize
 #   was declared "deprecated"
-WERROR_FLAGS := -Wall -Werror-all -w2 -diag-disable 271 -diag-warning 1478
+WERROR_FLAGS := -Wall -w2 -diag-disable 271 -diag-warning 1478
 WERROR_FLAGS += -diag-disable 13368 -diag-disable 15527
+ifeq ($(CONFIG_RTE_ERROR_ON_WARNING),y)
+WERROR_FLAGS += -Werror-all
+endif
+

 # process cpu flags
 include $(RTE_SDK)/mk/toolchain/$(RTE_TOOLCHAIN)/rte.toolchain-compat.mk
-- 
2.1.0



[dpdk-dev] [PATCH v5 18/19] ring: add sched_yield to avoid spin forever

2015-02-12 Thread Bruce Richardson
On Thu, Feb 12, 2015 at 01:08:43PM +, Ananyev, Konstantin wrote:
> 
> 
> > -Original Message-
> > From: Liang, Cunming
> > Sent: Thursday, February 12, 2015 1:05 PM
> > To: Olivier MATZ; dev at dpdk.org
> > Cc: Ananyev, Konstantin
> > Subject: RE: [PATCH v5 18/19] ring: add sched_yield to avoid spin forever
> > 
> > Hi,
> > 
> > > -Original Message-
> > > From: Olivier MATZ [mailto:olivier.matz at 6wind.com]
> > > Sent: Thursday, February 12, 2015 7:16 PM
> > > To: Liang, Cunming; dev at dpdk.org
> > > Cc: Ananyev, Konstantin
> > > Subject: Re: [PATCH v5 18/19] ring: add sched_yield to avoid spin forever
> > >
> > > Hi,
> > >
> > > On 02/12/2015 09:16 AM, Cunming Liang wrote:
> > > > Add a sched_yield() syscall if the thread spins for too long, waiting 
> > > > other thread
> > > to finish its operations on the ring.
> > > > That gives pre-empted thread a chance to proceed and finish with ring
> > > enqnue/dequeue operation.
> > > > The purpose is to reduce contention on the ring. By ring_perf_test, it 
> > > > doesn't
> > > shows additional perf penalty.
> > > >
> > > > Signed-off-by: Cunming Liang 
> > > > ---
> > > >   v5 changes:
> > > > add RTE_RING_PAUSE_REP to config file
> > > >
> > > >   v4 changes:
> > > > update and add more comments on sched_yield()
> > > >
> > > >   v3 changes:
> > > > new patch adding sched_yield() in rte_ring to avoid long spin
> > > >
> > > >   config/common_bsdapp   |  1 +
> > > >   config/common_linuxapp |  1 +
> > > >   lib/librte_ring/rte_ring.h | 31 +++
> > > >   3 files changed, 29 insertions(+), 4 deletions(-)
> > > >
> > > > diff --git a/config/common_bsdapp b/config/common_bsdapp
> > > > index 57bacb8..52c5143 100644
> > > > --- a/config/common_bsdapp
> > > > +++ b/config/common_bsdapp
> > > > @@ -234,6 +234,7 @@ CONFIG_RTE_PMD_PACKET_PREFETCH=y
> > > >   CONFIG_RTE_LIBRTE_RING=y
> > > >   CONFIG_RTE_LIBRTE_RING_DEBUG=n
> > > >   CONFIG_RTE_RING_SPLIT_PROD_CONS=n
> > > > +CONFIG_RTE_RING_PAUSE_REP=n
> > >
> > > Maybe it's better to use CONFIG_RTE_RING_PAUSE_REP=0 instead?
> > > If I understand well, it has to be set to an integer value to
> > > enable it, am I correct?
> > [LCM] If RTE_RING_PAUSE_REP=N (no define), by default will use 0. If it's 
> > set to 'y'(=1), will issue yield in the most frequent rate.
> > It also can set as integer to assign any number. All cases works for this 
> > configure.
> > One point is in configure file, just demonstrate the default way to use it.
> > It can't prevent to use anything unexpected. Except we rule the n & y 
> > illegal for this option.
> > The meaningful value of it can write in the doc.
> 
> I also think that it is better avoid 'y' and 'n' (though as you said it would 
> work), but use integers for all cases.
> Less confusion for the users.
> Konstantin 
> 
+1
Also expand "REP" to "REP_COUNT" to make it clear that it's a numeric value.

/Bruce


[dpdk-dev] [PATCH v5 18/19] ring: add sched_yield to avoid spin forever

2015-02-12 Thread Ananyev, Konstantin


> -Original Message-
> From: Liang, Cunming
> Sent: Thursday, February 12, 2015 1:05 PM
> To: Olivier MATZ; dev at dpdk.org
> Cc: Ananyev, Konstantin
> Subject: RE: [PATCH v5 18/19] ring: add sched_yield to avoid spin forever
> 
> Hi,
> 
> > -Original Message-
> > From: Olivier MATZ [mailto:olivier.matz at 6wind.com]
> > Sent: Thursday, February 12, 2015 7:16 PM
> > To: Liang, Cunming; dev at dpdk.org
> > Cc: Ananyev, Konstantin
> > Subject: Re: [PATCH v5 18/19] ring: add sched_yield to avoid spin forever
> >
> > Hi,
> >
> > On 02/12/2015 09:16 AM, Cunming Liang wrote:
> > > Add a sched_yield() syscall if the thread spins for too long, waiting 
> > > other thread
> > to finish its operations on the ring.
> > > That gives pre-empted thread a chance to proceed and finish with ring
> > enqnue/dequeue operation.
> > > The purpose is to reduce contention on the ring. By ring_perf_test, it 
> > > doesn't
> > shows additional perf penalty.
> > >
> > > Signed-off-by: Cunming Liang 
> > > ---
> > >   v5 changes:
> > > add RTE_RING_PAUSE_REP to config file
> > >
> > >   v4 changes:
> > > update and add more comments on sched_yield()
> > >
> > >   v3 changes:
> > > new patch adding sched_yield() in rte_ring to avoid long spin
> > >
> > >   config/common_bsdapp   |  1 +
> > >   config/common_linuxapp |  1 +
> > >   lib/librte_ring/rte_ring.h | 31 +++
> > >   3 files changed, 29 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/config/common_bsdapp b/config/common_bsdapp
> > > index 57bacb8..52c5143 100644
> > > --- a/config/common_bsdapp
> > > +++ b/config/common_bsdapp
> > > @@ -234,6 +234,7 @@ CONFIG_RTE_PMD_PACKET_PREFETCH=y
> > >   CONFIG_RTE_LIBRTE_RING=y
> > >   CONFIG_RTE_LIBRTE_RING_DEBUG=n
> > >   CONFIG_RTE_RING_SPLIT_PROD_CONS=n
> > > +CONFIG_RTE_RING_PAUSE_REP=n
> >
> > Maybe it's better to use CONFIG_RTE_RING_PAUSE_REP=0 instead?
> > If I understand well, it has to be set to an integer value to
> > enable it, am I correct?
> [LCM] If RTE_RING_PAUSE_REP=N (no define), by default will use 0. If it's set 
> to 'y'(=1), will issue yield in the most frequent rate.
> It also can set as integer to assign any number. All cases works for this 
> configure.
> One point is in configure file, just demonstrate the default way to use it.
> It can't prevent to use anything unexpected. Except we rule the n & y illegal 
> for this option.
> The meaningful value of it can write in the doc.

I also think that it is better avoid 'y' and 'n' (though as you said it would 
work), but use integers for all cases.
Less confusion for the users.
Konstantin 

> >
> > Thanks,
> > Olivier



[dpdk-dev] [PATCH v2 11/11] lib/librte_vhost: support dynamically registering vhost server

2015-02-12 Thread Huawei Xie
* support calling rte_vhost_driver_register after rte_vhost_driver_session_start
* add mutext to protect fdset from concurrent access
* add busy flag in fdentry. this flag is set before cb and cleared after cb is 
finished.

mutex lock scenario in vhost:

* event_dispatch(in rte_vhost_driver_session_start) runs in a seperate thread, 
infinitely
processing vhost messages through cb(callback).
* event_dispatch acquires the lock, get the cb and its context, mark the busy 
flag,
and releases the mutex.
* vserver_new_vq_conn cb calls fdset_add, which acquires the mutex and add new 
fd into fdset.
* vserver_message_handler cb frees data context, marks remove flag to request 
to delete
connfd(connection fd) from fdset.
* after cb returns, event_dispatch
  1. clears busy flag.
  2. if there is remove request, call fdset_del, which acquires mutex, checks 
busy flag, and
removes connfd from fdset.
* rte_vhost_driver_unregister(not implemented) runs in another thread, acquires 
the mutex,
calls fdset_del to remove fd(listenerfd) from fdset. Then it could free data 
context.

The above steps ensures fd data context isn't freed when cb is using.

VM(s) should have been shutdown before rte_vhost_driver_unregister.

Signed-off-by: Huawei Xie 
---
 lib/librte_vhost/vhost_user/fd_man.c | 63 +---
 lib/librte_vhost/vhost_user/fd_man.h |  5 ++-
 lib/librte_vhost/vhost_user/vhost-net-user.c | 34 +--
 3 files changed, 82 insertions(+), 20 deletions(-)

diff --git a/lib/librte_vhost/vhost_user/fd_man.c 
b/lib/librte_vhost/vhost_user/fd_man.c
index 929fbc3..63ac4df 100644
--- a/lib/librte_vhost/vhost_user/fd_man.c
+++ b/lib/librte_vhost/vhost_user/fd_man.c
@@ -40,6 +40,7 @@
 #include 
 #include 

+#include 
 #include 

 #include "fd_man.h"
@@ -145,6 +146,8 @@ fdset_add(struct fdset *pfdset, int fd, fd_cb rcb, fd_cb 
wcb, void *dat)
if (pfdset == NULL || fd == -1)
return -1;

+   pthread_mutex_lock(>fd_mutex);
+
/* Find a free slot in the list. */
i = fdset_find_free_slot(pfdset);
if (i == -1)
@@ -153,6 +156,8 @@ fdset_add(struct fdset *pfdset, int fd, fd_cb rcb, fd_cb 
wcb, void *dat)
fdset_add_fd(pfdset, i, fd, rcb, wcb, dat);
pfdset->num++;

+   pthread_mutex_unlock(>fd_mutex);
+
return 0;
 }

@@ -164,17 +169,36 @@ fdset_del(struct fdset *pfdset, int fd)
 {
int i;

+   if (pfdset == NULL || fd == -1)
+   return;
+
+again:
+   pthread_mutex_lock(>fd_mutex);
+
i = fdset_find_fd(pfdset, fd);
if (i != -1 && fd != -1) {
+   /* busy indicates r/wcb is executing! */
+   if (pfdset->fd[i].busy == 1) {
+   pthread_mutex_unlock(>fd_mutex);
+   goto again;
+   }
+
pfdset->fd[i].fd = -1;
pfdset->fd[i].rcb = pfdset->fd[i].wcb = NULL;
pfdset->num--;
}
+
+   pthread_mutex_unlock(>fd_mutex);
 }

 /**
  * This functions runs in infinite blocking loop until there is no fd in
  * pfdset. It calls corresponding r/w handler if there is event on the fd.
+ *
+ * Before the callback is called, we set the flag to busy status; If other
+ * thread(now rte_vhost_driver_unregister) calls fdset_del concurrently, it
+ * will wait until the flag is reset to zero(which indicates the callback is
+ * finished), then it could free the context after fdset_del.
  */
 void
 fdset_event_dispatch(struct fdset *pfdset)
@@ -183,6 +207,10 @@ fdset_event_dispatch(struct fdset *pfdset)
int i, maxfds;
struct fdentry *pfdentry;
int num = MAX_FDS;
+   fd_cb rcb, wcb;
+   void *dat;
+   int fd;
+   int remove1, remove2;

if (pfdset == NULL)
return;
@@ -190,18 +218,41 @@ fdset_event_dispatch(struct fdset *pfdset)
while (1) {
FD_ZERO();
FD_ZERO();
+   pthread_mutex_lock(>fd_mutex);
+
maxfds = fdset_fill(, , pfdset);
-   if (maxfds == -1)
-   return;
+   if (maxfds == -1) {
+   pthread_mutex_unlock(>fd_mutex);
+   sleep(1);
+   continue;
+   }
+
+   pthread_mutex_unlock(>fd_mutex);

select(maxfds + 1, , , NULL, NULL);

for (i = 0; i < num; i++) {
+   remove1 = remove2 = 0;
+   pthread_mutex_lock(>fd_mutex);
pfdentry = >fd[i];
-   if (pfdentry->fd >= 0 && FD_ISSET(pfdentry->fd, ) 
&& pfdentry->rcb)
-   pfdentry->rcb(pfdentry->fd, pfdentry->dat);
-   if (pfdentry->fd >= 0 && FD_ISSET(pfdentry->fd, ) 
&& pfdentry->wcb)
-   pfdentry->wcb(pfdentry->fd, pfdentry->dat);
+   fd = pfdentry->fd;
+   

[dpdk-dev] [PATCH v2 10/11] lib/librte_vhost: support dev->ifname for vhost-user

2015-02-12 Thread Huawei Xie
for vhost-cuse, ifname is the name of the tap device
for vhost-user, ifname is the name of the unix domain socket path

Signed-off-by: Huawei Xie 
---
 lib/librte_vhost/rte_virtio_net.h |  3 +-
 lib/librte_vhost/vhost-net.h  |  3 ++
 lib/librte_vhost/vhost_cuse/vhost-net-cdev.c  |  8 +++-
 lib/librte_vhost/vhost_cuse/virtio-net-cdev.c | 53 ++
 lib/librte_vhost/vhost_cuse/virtio-net-cdev.h |  3 ++
 lib/librte_vhost/vhost_user/vhost-net-user.c  |  7 +++
 lib/librte_vhost/virtio-net.c | 63 +--
 7 files changed, 95 insertions(+), 45 deletions(-)

diff --git a/lib/librte_vhost/rte_virtio_net.h 
b/lib/librte_vhost/rte_virtio_net.h
index 46c2072..611a3d4 100644
--- a/lib/librte_vhost/rte_virtio_net.h
+++ b/lib/librte_vhost/rte_virtio_net.h
@@ -100,7 +100,8 @@ struct virtio_net {
uint64_tfeatures;   /**< Negotiated feature set. */
uint64_tdevice_fh;  /**< device identifier. */
uint32_tflags;  /**< Device flags. Only used to 
check if device is running on data core. */
-   charifname[IFNAMSIZ];   /**< Name of the tap 
device. */
+#define IF_NAME_SZ (PATH_MAX > IFNAMSIZ ? PATH_MAX : IFNAMSIZ)
+   charifname[IF_NAME_SZ]; /**< Name of the tap 
device or socket path. */
void*priv;  /**< private context */
 } __rte_cache_aligned;

diff --git a/lib/librte_vhost/vhost-net.h b/lib/librte_vhost/vhost-net.h
index a56e405..0f3f8dc 100644
--- a/lib/librte_vhost/vhost-net.h
+++ b/lib/librte_vhost/vhost-net.h
@@ -93,6 +93,9 @@ struct vhost_net_device_ops {
int (*new_device)(struct vhost_device_ctx);
void (*destroy_device)(struct vhost_device_ctx);

+   void (*set_ifname)(struct vhost_device_ctx,
+   const char *if_name, unsigned int if_len);
+
int (*get_features)(struct vhost_device_ctx, uint64_t *);
int (*set_features)(struct vhost_device_ctx, uint64_t *);

diff --git a/lib/librte_vhost/vhost_cuse/vhost-net-cdev.c 
b/lib/librte_vhost/vhost_cuse/vhost-net-cdev.c
index 72609a3..6b68abf 100644
--- a/lib/librte_vhost/vhost_cuse/vhost-net-cdev.c
+++ b/lib/librte_vhost/vhost_cuse/vhost-net-cdev.c
@@ -196,7 +196,13 @@ vhost_net_ioctl(fuse_req_t req, int cmd, void *arg,
case VHOST_NET_SET_BACKEND:
LOG_DEBUG(VHOST_CONFIG,
"(%"PRIu64") IOCTL: VHOST_NET_SET_BACKEND\n", ctx.fh);
-   VHOST_IOCTL_R(struct vhost_vring_file, file, ops->set_backend);
+   if (!in_buf) {
+   VHOST_IOCTL_RETRY(sizeof(file), 0);
+   break;
+   }
+   file = *(const struct vhost_vring_file *)in_buf;
+   result = cuse_set_backend(ctx, );
+   fuse_reply_ioctl(req, result, NULL, 0);
break;

case VHOST_GET_FEATURES:
diff --git a/lib/librte_vhost/vhost_cuse/virtio-net-cdev.c 
b/lib/librte_vhost/vhost_cuse/virtio-net-cdev.c
index adebb54..ae2c3fa 100644
--- a/lib/librte_vhost/vhost_cuse/virtio-net-cdev.c
+++ b/lib/librte_vhost/vhost_cuse/virtio-net-cdev.c
@@ -43,6 +43,10 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
+#include 
 #include 

 #include 
@@ -51,6 +55,7 @@
 #include "vhost-net.h"
 #include "virtio-net-cdev.h"
 #include "virtio-net.h"
+#include "eventfd_copy.h"

 /* Line size for reading maps file. */
 static const uint32_t BUFSIZE = PATH_MAX;
@@ -368,3 +373,51 @@ cuse_set_mem_table(struct vhost_device_ctx ctx,

return 0;
 }
+
+/*
+ * Function to get the tap device name from the provided file descriptor and
+ * save it in the device structure.
+ */
+static int
+get_ifname(struct vhost_device_ctx ctx, struct virtio_net *dev, int tap_fd, 
int pid)
+{
+   int fd_tap;
+   struct ifreq ifr;
+   uint32_t ifr_size;
+   int ret;
+
+   fd_tap = eventfd_copy(tap_fd, pid);
+   if (fd_tap < 0)
+   return -1;
+
+   ret = ioctl(fd_tap, TUNGETIFF, );
+
+   if (close(fd_tap) < 0)
+   RTE_LOG(ERR, VHOST_CONFIG,
+   "(%"PRIu64") fd close failed\n",
+   dev->device_fh);
+
+   if (ret >= 0) {
+   ifr_size = strnlen(ifr.ifr_name, sizeof(ifr.ifr_name));
+   ops->set_ifname(ctx, ifr.ifr_name, ifr_size);
+   } else
+   RTE_LOG(ERR, VHOST_CONFIG,
+   "(%"PRIu64") TUNGETIFF ioctl failed\n",
+   dev->device_fh);
+
+   return 0;
+}
+
+int cuse_set_backend(struct vhost_device_ctx ctx, struct vhost_vring_file 
*file)
+{
+   struct virtio_net *dev;
+
+   dev = get_device(ctx);
+   if (dev == NULL)
+   return -1;
+
+   if (!(dev->flags & VIRTIO_DEV_RUNNING) && file->fd != 
VIRTIO_DEV_STOPPED)
+   get_ifname(ctx, dev, file->fd, ctx.pid);
+
+   return 

[dpdk-dev] [PATCH v2 09/11] lib/librte_vhost: vhost user support

2015-02-12 Thread Huawei Xie
In rte_vhost_driver_register(), vhost unix domain socket listener fd is created
and added to polled(based on select) fdset.

In rte_vhost_driver_session_start(), fds in the fdset are checked for
processing. If there is new connection from qemu, connection fd accepted is
added to polled fdset. The listener and connection fds in the fdset are
then both checked. When there is message on the connection fd, its
callback vserver_message_handler is called to process vhost-user messages.

To support identifying which virtio is from which guest VM, we could call
rte_vhost_driver_register with different socket path. Virtio devices from
same VM will connect to VM specific socket. The socket path information is
stored in the virtio_net structure.

Signed-off-by: Huawei Xie 
---
 lib/librte_vhost/Makefile |   8 +-
 lib/librte_vhost/rte_virtio_net.h |   2 +
 lib/librte_vhost/vhost-net.h  |   4 +-
 lib/librte_vhost/vhost_user/vhost-net-user.c  | 457 ++
 lib/librte_vhost/vhost_user/vhost-net-user.h  | 106 ++
 lib/librte_vhost/vhost_user/virtio-net-user.c | 314 ++
 lib/librte_vhost/vhost_user/virtio-net-user.h |  49 +++
 lib/librte_vhost/virtio-net.c |  20 +-
 8 files changed, 951 insertions(+), 9 deletions(-)
 create mode 100644 lib/librte_vhost/vhost_user/vhost-net-user.c
 create mode 100644 lib/librte_vhost/vhost_user/vhost-net-user.h
 create mode 100644 lib/librte_vhost/vhost_user/virtio-net-user.c
 create mode 100644 lib/librte_vhost/vhost_user/virtio-net-user.h

diff --git a/lib/librte_vhost/Makefile b/lib/librte_vhost/Makefile
index 797a806..52f6575 100644
--- a/lib/librte_vhost/Makefile
+++ b/lib/librte_vhost/Makefile
@@ -38,10 +38,14 @@ EXPORT_MAP := rte_vhost_version.map

 LIBABIVER := 1

-CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) -I vhost_cuse -O3 -D_FILE_OFFSET_BITS=64 
-lfuse
+CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) -O3 -D_FILE_OFFSET_BITS=64
+CFLAGS += -I vhost_cuse -lfuse
+CFLAGS += -I vhost_user
 LDFLAGS += -lfuse
 # all source are stored in SRCS-y
-SRCS-$(CONFIG_RTE_LIBRTE_VHOST) := vhost_cuse/vhost-net-cdev.c 
vhost_cuse/virtio-net-cdev.c vhost_cuse/eventfd_copy.c virtio-net.c vhost_rxtx.c
+SRCS-$(CONFIG_RTE_LIBRTE_VHOST) := virtio-net.c vhost_rxtx.c
+#SRCS-$(CONFIG_RTE_LIBRTE_VHOST) += vhost_cuse/vhost-net-cdev.c 
vhost_cuse/virtio-net-cdev.c vhost_cuse/eventfd_copy.c
+SRCS-$(CONFIG_RTE_LIBRTE_VHOST) += vhost_user/vhost-net-user.c 
vhost_user/virtio-net-user.c vhost_user/fd_man.c

 # install includes
 SYMLINK-$(CONFIG_RTE_LIBRTE_VHOST)-include += rte_virtio_net.h
diff --git a/lib/librte_vhost/rte_virtio_net.h 
b/lib/librte_vhost/rte_virtio_net.h
index 0bf07c7..46c2072 100644
--- a/lib/librte_vhost/rte_virtio_net.h
+++ b/lib/librte_vhost/rte_virtio_net.h
@@ -50,6 +50,8 @@
 #include 
 #include 

+#define VHOST_MEMORY_MAX_NREGIONS 8
+
 /* Used to indicate that the device is running on a data core */
 #define VIRTIO_DEV_RUNNING 1

diff --git a/lib/librte_vhost/vhost-net.h b/lib/librte_vhost/vhost-net.h
index 86b38a5..a56e405 100644
--- a/lib/librte_vhost/vhost-net.h
+++ b/lib/librte_vhost/vhost-net.h
@@ -41,7 +41,9 @@

 #include 

-#define VHOST_MEMORY_MAX_NREGIONS 8
+#include "rte_virtio_net.h"
+
+extern struct vhost_net_device_ops const *ops;

 /* Macros for printing using RTE_LOG */
 #define RTE_LOGTYPE_VHOST_CONFIG RTE_LOGTYPE_USER1
diff --git a/lib/librte_vhost/vhost_user/vhost-net-user.c 
b/lib/librte_vhost/vhost_user/vhost-net-user.c
new file mode 100644
index 000..712a82f
--- /dev/null
+++ b/lib/librte_vhost/vhost_user/vhost-net-user.c
@@ -0,0 +1,457 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+ *   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 Intel 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, 

[dpdk-dev] [PATCH v2 08/11] lib/librte_vhost: add select based event driven processing

2015-02-12 Thread Huawei Xie
for more generic event driven processing, refer to:
http://libevent.org/


Signed-off-by: Huawei Xie 
---
 lib/librte_vhost/vhost_user/fd_man.c | 207 +++
 lib/librte_vhost/vhost_user/fd_man.h |  64 +++
 2 files changed, 271 insertions(+)
 create mode 100644 lib/librte_vhost/vhost_user/fd_man.c
 create mode 100644 lib/librte_vhost/vhost_user/fd_man.h

diff --git a/lib/librte_vhost/vhost_user/fd_man.c 
b/lib/librte_vhost/vhost_user/fd_man.c
new file mode 100644
index 000..929fbc3
--- /dev/null
+++ b/lib/librte_vhost/vhost_user/fd_man.c
@@ -0,0 +1,207 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+ *   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 Intel 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 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include "fd_man.h"
+
+/**
+ * Returns the index in the fdset for a given fd.
+ * If fd is -1, it means to search for a free entry.
+ * @return
+ *   index for the fd, or -1 if fd isn't in the fdset.
+ */
+static int
+fdset_find_fd(struct fdset *pfdset, int fd)
+{
+   int i;
+
+   if (pfdset == NULL)
+   return -1;
+
+   for (i = 0; i < MAX_FDS && pfdset->fd[i].fd != fd; i++)
+   ;
+
+   return i ==  MAX_FDS ? -1 : i;
+}
+
+static int
+fdset_find_free_slot(struct fdset *pfdset)
+{
+   return fdset_find_fd(pfdset, -1);
+}
+
+static void
+fdset_add_fd(struct fdset  *pfdset, int idx, int fd,
+   fd_cb rcb, fd_cb wcb, void *dat)
+{
+   struct fdentry *pfdentry;
+
+   if (pfdset == NULL || idx >= MAX_FDS)
+   return;
+
+   pfdentry = >fd[idx];
+   pfdentry->fd = fd;
+   pfdentry->rcb = rcb;
+   pfdentry->wcb = wcb;
+   pfdentry->dat = dat;
+}
+
+/**
+ * Fill the read/write fd_set with the fds in the fdset.
+ * @return
+ *  the maximum fds filled in the read/write fd_set.
+ */
+static int
+fdset_fill(fd_set *rfset, fd_set *wfset, struct fdset *pfdset)
+{
+   struct fdentry *pfdentry;
+   int i, maxfds = -1;
+   int num = MAX_FDS;
+
+   if (pfdset == NULL)
+   return -1;
+
+   for (i = 0; i < num; i++) {
+   pfdentry = >fd[i];
+   if (pfdentry->fd != -1) {
+   int added = 0;
+   if (pfdentry->rcb && rfset) {
+   FD_SET(pfdentry->fd, rfset);
+   added = 1;
+   }
+   if (pfdentry->wcb && wfset) {
+   FD_SET(pfdentry->fd, wfset);
+   added = 1;
+   }
+   if (added)
+   maxfds = pfdentry->fd < maxfds ?
+   maxfds : pfdentry->fd;
+   }
+   }
+   return maxfds;
+}
+
+void
+fdset_init(struct fdset *pfdset)
+{
+   int i;
+
+   if (pfdset == NULL)
+   return;
+
+   for (i = 0; i < MAX_FDS; i++)
+   pfdset->fd[i].fd = -1;
+   pfdset->num = 0;
+}
+
+/**
+ * Register the fd in the fdset with read/write handler and context.
+ */
+int
+fdset_add(struct fdset *pfdset, int fd, fd_cb rcb, fd_cb wcb, void *dat)
+{
+   int i;
+
+   if (pfdset == NULL || fd == -1)
+   return -1;
+
+   /* Find a free slot in the list. */
+

[dpdk-dev] [PATCH v2 07/11] lib/librte_vhost: implement cuse_set_memory_table

2015-02-12 Thread Huawei Xie
remove set_memory_table ops

vhost-cuse or vhost-user will both implement their own set_memory_region 
handler.

In current vhost-cuse implementation, guest numa memory isn't supported.
Assume that guest memory is backed by only one file.

Signed-off-by: Huawei Xie 
---
 lib/librte_vhost/Makefile |   2 +-
 lib/librte_vhost/vhost-net.h  |   4 +-
 lib/librte_vhost/vhost_cuse/vhost-net-cdev.c  |   7 +-
 lib/librte_vhost/vhost_cuse/virtio-net-cdev.c | 115 +
 lib/librte_vhost/vhost_cuse/virtio-net-cdev.h |  45 
 lib/librte_vhost/virtio-net.c | 348 --
 lib/librte_vhost/virtio-net.h |  43 
 7 files changed, 210 insertions(+), 354 deletions(-)
 create mode 100644 lib/librte_vhost/vhost_cuse/virtio-net-cdev.h
 create mode 100644 lib/librte_vhost/virtio-net.h

diff --git a/lib/librte_vhost/Makefile b/lib/librte_vhost/Makefile
index 88d1295..797a806 100644
--- a/lib/librte_vhost/Makefile
+++ b/lib/librte_vhost/Makefile
@@ -41,7 +41,7 @@ LIBABIVER := 1
 CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) -I vhost_cuse -O3 -D_FILE_OFFSET_BITS=64 
-lfuse
 LDFLAGS += -lfuse
 # all source are stored in SRCS-y
-SRCS-$(CONFIG_RTE_LIBRTE_VHOST) := vhost_cuse/vhost-net-cdev.c 
vhost_cuse/eventfd_copy.c virtio-net.c vhost_rxtx.c
+SRCS-$(CONFIG_RTE_LIBRTE_VHOST) := vhost_cuse/vhost-net-cdev.c 
vhost_cuse/virtio-net-cdev.c vhost_cuse/eventfd_copy.c virtio-net.c vhost_rxtx.c

 # install includes
 SYMLINK-$(CONFIG_RTE_LIBRTE_VHOST)-include += rte_virtio_net.h
diff --git a/lib/librte_vhost/vhost-net.h b/lib/librte_vhost/vhost-net.h
index 03a5c57..86b38a5 100644
--- a/lib/librte_vhost/vhost-net.h
+++ b/lib/librte_vhost/vhost-net.h
@@ -41,6 +41,8 @@

 #include 

+#define VHOST_MEMORY_MAX_NREGIONS 8
+
 /* Macros for printing using RTE_LOG */
 #define RTE_LOGTYPE_VHOST_CONFIG RTE_LOGTYPE_USER1
 #define RTE_LOGTYPE_VHOST_DATA   RTE_LOGTYPE_USER1
@@ -92,8 +94,6 @@ struct vhost_net_device_ops {
int (*get_features)(struct vhost_device_ctx, uint64_t *);
int (*set_features)(struct vhost_device_ctx, uint64_t *);

-   int (*set_mem_table)(struct vhost_device_ctx, const void *, uint32_t);
-
int (*set_vring_num)(struct vhost_device_ctx, struct vhost_vring_state 
*);
int (*set_vring_addr)(struct vhost_device_ctx, struct vhost_vring_addr 
*);
int (*set_vring_base)(struct vhost_device_ctx, struct vhost_vring_state 
*);
diff --git a/lib/librte_vhost/vhost_cuse/vhost-net-cdev.c 
b/lib/librte_vhost/vhost_cuse/vhost-net-cdev.c
index e7794b0..72609a3 100644
--- a/lib/librte_vhost/vhost_cuse/vhost-net-cdev.c
+++ b/lib/librte_vhost/vhost_cuse/vhost-net-cdev.c
@@ -44,6 +44,7 @@
 #include 
 #include 

+#include "virtio-net-cdev.h"
 #include "vhost-net.h"
 #include "eventfd_copy.h"

@@ -57,7 +58,7 @@ static const char cuse_device_name[] = "/dev/cuse";
 static const char default_cdev[] = "vhost-net";

 static struct fuse_session *session;
-static struct vhost_net_device_ops const *ops;
+struct vhost_net_device_ops const *ops;

 /*
  * Returns vhost_device_ctx from given fuse_req_t. The index is populated later
@@ -247,8 +248,8 @@ vhost_net_ioctl(fuse_req_t req, int cmd, void *arg,
break;

default:
-   result = ops->set_mem_table(ctx,
-   in_buf, mem_temp.nregions);
+   result = cuse_set_mem_table(ctx, in_buf,
+   mem_temp.nregions);
if (result)
fuse_reply_err(req, EINVAL);
else
diff --git a/lib/librte_vhost/vhost_cuse/virtio-net-cdev.c 
b/lib/librte_vhost/vhost_cuse/virtio-net-cdev.c
index 58ac3dd..adebb54 100644
--- a/lib/librte_vhost/vhost_cuse/virtio-net-cdev.c
+++ b/lib/librte_vhost/vhost_cuse/virtio-net-cdev.c
@@ -47,7 +47,10 @@

 #include 

+#include "rte_virtio_net.h"
 #include "vhost-net.h"
+#include "virtio-net-cdev.h"
+#include "virtio-net.h"

 /* Line size for reading maps file. */
 static const uint32_t BUFSIZE = PATH_MAX;
@@ -253,3 +256,115 @@ host_memory_map(pid_t pid, uint64_t addr,

return 0;
 }
+
+int
+cuse_set_mem_table(struct vhost_device_ctx ctx,
+   const struct vhost_memory *mem_regions_addr, uint32_t nregions)
+{
+   uint64_t size = offsetof(struct vhost_memory, regions);
+   uint32_t idx, valid_regions;
+   struct virtio_memory_regions *pregion;
+   struct vhost_memory_region *mem_regions = (void *)(uintptr_t)
+   ((uint64_t)(uintptr_t)mem_regions_addr + size);
+   uint64_t base_address = 0, mapped_address, mapped_size;
+   struct virtio_net *dev;
+
+   dev = get_device(ctx);
+   if (dev == NULL)
+   return -1;
+
+   if (dev->mem && dev->mem->mapped_address) {
+   munmap((void *)(uintptr_t)dev->mem->mapped_address,
+   (size_t)dev->mem->mapped_size);
+   

[dpdk-dev] [PATCH v2 06/11] lib/librte_vhost: make host_memory_map a more generic function.

2015-02-12 Thread Huawei Xie
This functions accepts a virtual address and pid(qemu), and maps it into
current process(vhost)'s address space.

The memory behind the virtual address should be backed by a file,
and virtual address should be the starting address.

Signed-off-by: Huawei Xie 
---
 lib/librte_vhost/vhost_cuse/virtio-net-cdev.c | 42 +--
 1 file changed, 20 insertions(+), 22 deletions(-)

diff --git a/lib/librte_vhost/vhost_cuse/virtio-net-cdev.c 
b/lib/librte_vhost/vhost_cuse/virtio-net-cdev.c
index baca379..58ac3dd 100644
--- a/lib/librte_vhost/vhost_cuse/virtio-net-cdev.c
+++ b/lib/librte_vhost/vhost_cuse/virtio-net-cdev.c
@@ -75,8 +75,8 @@ struct procmap {
  * map it to our address space.
  */
 static int
-host_memory_map(struct virtio_net *dev, struct virtio_memory *mem,
-   pid_t pid, uint64_t addr)
+host_memory_map(pid_t pid, uint64_t addr,
+   uint64_t *mapped_address, uint64_t *mapped_size)
 {
struct dirent *dptr = NULL;
struct procmap procmap;
@@ -104,8 +104,8 @@ host_memory_map(struct virtio_net *dev, struct 
virtio_memory *mem,
fmap = fopen(mapfile, "r");
if (fmap == NULL) {
RTE_LOG(ERR, VHOST_CONFIG,
-   "(%"PRIu64") Failed to open maps file for pid %d\n",
-   dev->device_fh, pid);
+   "Failed to open maps file for pid %d\n",
+   pid);
return -1;
}

@@ -179,8 +179,8 @@ host_memory_map(struct virtio_net *dev, struct 
virtio_memory *mem,

if (!found) {
RTE_LOG(ERR, VHOST_CONFIG,
-   "(%"PRIu64") Failed to find memory file in pid %d maps 
file\n",
-   dev->device_fh, pid);
+   "Failed to find memory file in pid %d maps file\n",
+   pid);
return -1;
}

@@ -188,8 +188,8 @@ host_memory_map(struct virtio_net *dev, struct 
virtio_memory *mem,
dp = opendir(procdir);
if (dp == NULL) {
RTE_LOG(ERR, VHOST_CONFIG,
-   "(%"PRIu64") Cannot open pid %d process directory\n",
-   dev->device_fh, pid);
+   "Cannot open pid %d process directory\n",
+   pid);
return -1;
}

@@ -202,8 +202,7 @@ host_memory_map(struct virtio_net *dev, struct 
virtio_memory *mem,
path = realpath(memfile, resolved_path);
if ((path == NULL) && (strlen(resolved_path) == 0)) {
RTE_LOG(ERR, VHOST_CONFIG,
-   "(%"PRIu64") Failed to resolve fd directory\n",
-   dev->device_fh);
+   "Failed to resolve fd directory\n");
closedir(dp);
return -1;
}
@@ -218,8 +217,8 @@ host_memory_map(struct virtio_net *dev, struct 
virtio_memory *mem,

if (found == 0) {
RTE_LOG(ERR, VHOST_CONFIG,
-   "(%"PRIu64") Failed to find memory file for pid %d\n",
-   dev->device_fh, pid);
+   "Failed to find memory file for pid %d\n",
+   pid);
return -1;
}
/* Open the shared memory file and map the memory into this process. */
@@ -227,31 +226,30 @@ host_memory_map(struct virtio_net *dev, struct 
virtio_memory *mem,

if (fd == -1) {
RTE_LOG(ERR, VHOST_CONFIG,
-   "(%"PRIu64") Failed to open %s for pid %d\n",
-   dev->device_fh, memfile, pid);
+   "Failed to open %s for pid %d\n",
+   memfile, pid);
return -1;
}

map = mmap(0, (size_t)procmap.len, PROT_READ|PROT_WRITE,
-   MAP_POPULATE|MAP_SHARED, fd, 0);
+   MAP_POPULATE|MAP_SHARED, fd, 0);
close(fd);

if (map == MAP_FAILED) {
RTE_LOG(ERR, VHOST_CONFIG,
-   "(%"PRIu64") Error mapping the file %s for pid %d\n",
-   dev->device_fh, memfile, pid);
+   "Error mapping the file %s for pid %d\n",
+   memfile, pid);
return -1;
}

/* Store the memory address and size in the device data structure */
-   mem->mapped_address = (uint64_t)(uintptr_t)map;
-   mem->mapped_size = procmap.len;
+   *mapped_address = (uint64_t)(uintptr_t)map;
+   *mapped_size = procmap.len;

LOG_DEBUG(VHOST_CONFIG,
-   "(%"PRIu64") Mem File: %s->%s - Size: %llu - VA: %p\n",
-   dev->device_fh,
+   "Mem File: %s->%s - Size: %llu - VA: %p\n",
memfile, resolved_path,
-   (unsigned long long)mem->mapped_size, map);
+   (unsigned long long)*mapped_size, map);

return 0;
 }
-- 
1.8.1.4



[dpdk-dev] [PATCH v2 04/11] lib/librte_vhost: move fd copying(from qemu process into vhost process) to eventfd_copy.c

2015-02-12 Thread Huawei Xie
 vhost-user doesn't need eventfd kernel module to copy fds between processes.

Signed-off-by: Huawei Xie 
---
 lib/librte_vhost/Makefile|  2 +-
 lib/librte_vhost/vhost_cuse/eventfd_copy.c   | 88 
 lib/librte_vhost/vhost_cuse/eventfd_copy.h   | 39 
 lib/librte_vhost/vhost_cuse/vhost-net-cdev.c | 41 +
 lib/librte_vhost/virtio-net.c| 57 +-
 5 files changed, 161 insertions(+), 66 deletions(-)
 create mode 100644 lib/librte_vhost/vhost_cuse/eventfd_copy.c
 create mode 100644 lib/librte_vhost/vhost_cuse/eventfd_copy.h

diff --git a/lib/librte_vhost/Makefile b/lib/librte_vhost/Makefile
index 49ae7ae..88d1295 100644
--- a/lib/librte_vhost/Makefile
+++ b/lib/librte_vhost/Makefile
@@ -41,7 +41,7 @@ LIBABIVER := 1
 CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) -I vhost_cuse -O3 -D_FILE_OFFSET_BITS=64 
-lfuse
 LDFLAGS += -lfuse
 # all source are stored in SRCS-y
-SRCS-$(CONFIG_RTE_LIBRTE_VHOST) := vhost_cuse/vhost-net-cdev.c virtio-net.c 
vhost_rxtx.c
+SRCS-$(CONFIG_RTE_LIBRTE_VHOST) := vhost_cuse/vhost-net-cdev.c 
vhost_cuse/eventfd_copy.c virtio-net.c vhost_rxtx.c

 # install includes
 SYMLINK-$(CONFIG_RTE_LIBRTE_VHOST)-include += rte_virtio_net.h
diff --git a/lib/librte_vhost/vhost_cuse/eventfd_copy.c 
b/lib/librte_vhost/vhost_cuse/eventfd_copy.c
new file mode 100644
index 000..4d697a2
--- /dev/null
+++ b/lib/librte_vhost/vhost_cuse/eventfd_copy.c
@@ -0,0 +1,88 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+ *   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 Intel 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 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include "eventfd_link/eventfd_link.h"
+#include "eventfd_copy.h"
+#include "vhost-net.h"
+
+static const char eventfd_cdev[] = "/dev/eventfd-link";
+
+/*
+ * This function uses the eventfd_link kernel module to copy an eventfd file
+ * descriptor provided by QEMU in to our process space.
+ */
+int
+eventfd_copy(int target_fd, int target_pid)
+{
+   int eventfd_link, ret;
+   struct eventfd_copy eventfd_copy;
+   int fd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
+
+   if (fd == -1)
+   return -1;
+
+   /* Open the character device to the kernel module. */
+   /* TODO: check this earlier rather than fail until VM boots! */
+   eventfd_link = open(eventfd_cdev, O_RDWR);
+   if (eventfd_link < 0) {
+   RTE_LOG(ERR, VHOST_CONFIG,
+   "eventfd_link module is not loaded\n");
+   close(fd);
+   return -1;
+   }
+
+   eventfd_copy.source_fd = fd;
+   eventfd_copy.target_fd = target_fd;
+   eventfd_copy.target_pid = target_pid;
+   /* Call the IOCTL to copy the eventfd. */
+   ret = ioctl(eventfd_link, EVENTFD_COPY, _copy);
+   close(eventfd_link);
+
+   if (ret < 0) {
+   RTE_LOG(ERR, VHOST_CONFIG,
+   "EVENTFD_COPY ioctl failed\n");
+   close(fd);
+   return -1;
+   }
+
+   return fd;
+}
diff --git a/lib/librte_vhost/vhost_cuse/eventfd_copy.h 
b/lib/librte_vhost/vhost_cuse/eventfd_copy.h
new file mode 100644
index 000..19ae30d
--- /dev/null
+++ b/lib/librte_vhost/vhost_cuse/eventfd_copy.h
@@ -0,0 +1,39 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2010-2014 Intel Corporation. All rights 

[dpdk-dev] [PATCH v2 03/11] lib/librte_vhost: rename vhost-net-cdev.h to vhost-net.h

2015-02-12 Thread Huawei Xie
This file defines common operations provided by virtio-net(.c).

Signed-off-by: Huawei Xie 
---
 lib/librte_vhost/vhost-net-cdev.h| 113 ---
 lib/librte_vhost/vhost-net.h | 113 +++
 lib/librte_vhost/vhost_cuse/vhost-net-cdev.c |   2 +-
 lib/librte_vhost/vhost_rxtx.c|   2 +-
 lib/librte_vhost/virtio-net.c|   2 +-
 5 files changed, 116 insertions(+), 116 deletions(-)
 delete mode 100644 lib/librte_vhost/vhost-net-cdev.h
 create mode 100644 lib/librte_vhost/vhost-net.h

diff --git a/lib/librte_vhost/vhost-net-cdev.h 
b/lib/librte_vhost/vhost-net-cdev.h
deleted file mode 100644
index 03a5c57..000
--- a/lib/librte_vhost/vhost-net-cdev.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/*-
- *   BSD LICENSE
- *
- *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
- *   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 Intel 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 _VHOST_NET_CDEV_H_
-#define _VHOST_NET_CDEV_H_
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#include 
-
-/* Macros for printing using RTE_LOG */
-#define RTE_LOGTYPE_VHOST_CONFIG RTE_LOGTYPE_USER1
-#define RTE_LOGTYPE_VHOST_DATA   RTE_LOGTYPE_USER1
-
-#ifdef RTE_LIBRTE_VHOST_DEBUG
-#define VHOST_MAX_PRINT_BUFF 6072
-#define LOG_LEVEL RTE_LOG_DEBUG
-#define LOG_DEBUG(log_type, fmt, args...) RTE_LOG(DEBUG, log_type, fmt, ##args)
-#define PRINT_PACKET(device, addr, size, header) do { \
-   char *pkt_addr = (char *)(addr); \
-   unsigned int index; \
-   char packet[VHOST_MAX_PRINT_BUFF]; \
-   \
-   if ((header)) \
-   snprintf(packet, VHOST_MAX_PRINT_BUFF, "(%"PRIu64") Header size 
%d: ", (device->device_fh), (size)); \
-   else \
-   snprintf(packet, VHOST_MAX_PRINT_BUFF, "(%"PRIu64") Packet size 
%d: ", (device->device_fh), (size)); \
-   for (index = 0; index < (size); index++) { \
-   snprintf(packet + strnlen(packet, VHOST_MAX_PRINT_BUFF), 
VHOST_MAX_PRINT_BUFF - strnlen(packet, VHOST_MAX_PRINT_BUFF), \
-   "%02hhx ", pkt_addr[index]); \
-   } \
-   snprintf(packet + strnlen(packet, VHOST_MAX_PRINT_BUFF), 
VHOST_MAX_PRINT_BUFF - strnlen(packet, VHOST_MAX_PRINT_BUFF), "\n"); \
-   \
-   LOG_DEBUG(VHOST_DATA, "%s", packet); \
-} while (0)
-#else
-#define LOG_LEVEL RTE_LOG_INFO
-#define LOG_DEBUG(log_type, fmt, args...) do {} while (0)
-#define PRINT_PACKET(device, addr, size, header) do {} while (0)
-#endif
-
-
-/*
- * Structure used to identify device context.
- */
-struct vhost_device_ctx {
-   pid_t   pid;/* PID of process calling the IOCTL. */
-   uint64_tfh; /* Populated with fi->fh to track the device 
index. */
-};
-
-/*
- * Structure contains function pointers to be defined in virtio-net.c. These
- * functions are called in CUSE context and are used to configure devices.
- */
-struct vhost_net_device_ops {
-   int (*new_device)(struct vhost_device_ctx);
-   void (*destroy_device)(struct vhost_device_ctx);
-
-   int (*get_features)(struct vhost_device_ctx, uint64_t *);
-   int (*set_features)(struct vhost_device_ctx, uint64_t *);
-
-   int (*set_mem_table)(struct vhost_device_ctx, const void *, uint32_t);
-
-   int (*set_vring_num)(struct vhost_device_ctx, struct vhost_vring_state 
*);
-   int (*set_vring_addr)(struct vhost_device_ctx, struct 

[dpdk-dev] [PATCH v2 02/11] lib/librte_vhost: create vhost_cuse directory and move vhost-net-cdev.c into vhost_cuse

2015-02-12 Thread Huawei Xie
vhost-cuse driver will be divided into two parts: cuse driver specific message
handling(in cuse directory) and common message handling(in virtio-net.c).

vhost ioctl message is pre-processed in cuse and then sent to virtio-net
if is not terminated.

virtio-net.c provides common message handling for both vhost-cuse and 
vhost-user.

Signed-off-by: Huawei Xie 
---
 lib/librte_vhost/Makefile|   4 +-
 lib/librte_vhost/vhost-net-cdev.c| 389 ---
 lib/librte_vhost/vhost_cuse/vhost-net-cdev.c | 389 +++
 3 files changed, 391 insertions(+), 391 deletions(-)
 delete mode 100644 lib/librte_vhost/vhost-net-cdev.c
 create mode 100644 lib/librte_vhost/vhost_cuse/vhost-net-cdev.c

diff --git a/lib/librte_vhost/Makefile b/lib/librte_vhost/Makefile
index 369c25a..49ae7ae 100644
--- a/lib/librte_vhost/Makefile
+++ b/lib/librte_vhost/Makefile
@@ -38,10 +38,10 @@ EXPORT_MAP := rte_vhost_version.map

 LIBABIVER := 1

-CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) -O3 -D_FILE_OFFSET_BITS=64 -lfuse
+CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) -I vhost_cuse -O3 -D_FILE_OFFSET_BITS=64 
-lfuse
 LDFLAGS += -lfuse
 # all source are stored in SRCS-y
-SRCS-$(CONFIG_RTE_LIBRTE_VHOST) := vhost-net-cdev.c virtio-net.c vhost_rxtx.c
+SRCS-$(CONFIG_RTE_LIBRTE_VHOST) := vhost_cuse/vhost-net-cdev.c virtio-net.c 
vhost_rxtx.c

 # install includes
 SYMLINK-$(CONFIG_RTE_LIBRTE_VHOST)-include += rte_virtio_net.h
diff --git a/lib/librte_vhost/vhost-net-cdev.c 
b/lib/librte_vhost/vhost-net-cdev.c
deleted file mode 100644
index 57c76cb..000
--- a/lib/librte_vhost/vhost-net-cdev.c
+++ /dev/null
@@ -1,389 +0,0 @@
-/*-
- *   BSD LICENSE
- *
- *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
- *   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 Intel 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 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#include 
-#include 
-#include 
-#include 
-
-#include "vhost-net-cdev.h"
-
-#define FUSE_OPT_DUMMY "\0\0"
-#define FUSE_OPT_FORE  "-f\0\0"
-#define FUSE_OPT_NOMULTI "-s\0\0"
-
-static const uint32_t default_major = 231;
-static const uint32_t default_minor = 1;
-static const char cuse_device_name[] = "/dev/cuse";
-static const char default_cdev[] = "vhost-net";
-
-static struct fuse_session *session;
-static struct vhost_net_device_ops const *ops;
-
-/*
- * Returns vhost_device_ctx from given fuse_req_t. The index is populated later
- * when the device is added to the device linked list.
- */
-static struct vhost_device_ctx
-fuse_req_to_vhost_ctx(fuse_req_t req, struct fuse_file_info *fi)
-{
-   struct vhost_device_ctx ctx;
-   struct fuse_ctx const *const req_ctx = fuse_req_ctx(req);
-
-   ctx.pid = req_ctx->pid;
-   ctx.fh = fi->fh;
-
-   return ctx;
-}
-
-/*
- * When the device is created in QEMU it gets initialised here and
- * added to the device linked list.
- */
-static void
-vhost_net_open(fuse_req_t req, struct fuse_file_info *fi)
-{
-   struct vhost_device_ctx ctx = fuse_req_to_vhost_ctx(req, fi);
-   int err = 0;
-
-   err = ops->new_device(ctx);
-   if (err == -1) {
-   fuse_reply_err(req, EPERM);
-   return;
-   }
-
-   fi->fh = err;
-
-   RTE_LOG(INFO, VHOST_CONFIG,
-   "(%"PRIu64") Device configuration started\n", fi->fh);
-   fuse_reply_open(req, fi);
-}
-
-/*
- * When QEMU is shutdown or killed the 

  1   2   >