[dpdk-dev] [PATCH 4/4] testpmd: extend commands for filter's input set changing

2015-12-25 Thread Jingjing Wu
This patch extends commands for filter's input set changing.
It added tos, protocol and ttl as filter's input fields, and
remove the words selection from flex payloads for flow director.

Signed-off-by: Jingjing Wu 
---
 app/test-pmd/cmdline.c  | 100 ++--
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  34 +-
 2 files changed, 97 insertions(+), 37 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 73298c9..da1d3f2 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -640,6 +640,7 @@ static void cmd_help_long_parsed(void *parsed_result,
"flow_director_filter (port_id) mode IP 
(add|del|update)"
" flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
" src (src_ip_address) dst (dst_ip_address)"
+   " tos (tos_value) proto (proto_value) ttl (ttl_value)"
" vlan (vlan_value) flexbytes (flexbytes_value)"
" (drop|fwd) pf|vf(vf_id) queue (queue_id)"
" fd_id (fd_id_value)\n"
@@ -649,6 +650,7 @@ static void cmd_help_long_parsed(void *parsed_result,
" flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
" src (src_ip_address) (src_port)"
" dst (dst_ip_address) (dst_port)"
+   " tos (tos_value) ttl (ttl_value)"
" vlan (vlan_value) flexbytes (flexbytes_value)"
" (drop|fwd) pf|vf(vf_id) queue (queue_id)"
" fd_id (fd_id_value)\n"
@@ -658,7 +660,9 @@ static void cmd_help_long_parsed(void *parsed_result,
" flow (ipv4-sctp|ipv6-sctp)"
" src (src_ip_address) (src_port)"
" dst (dst_ip_address) (dst_port)"
-   " tag (verification_tag) vlan (vlan_value)"
+   " tag (verification_tag) "
+   " tos (tos_value) ttl (ttl_value)"
+   " vlan (vlan_value)"
" flexbytes (flexbytes_value) (drop|fwd)"
" pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
"Add/Del a SCTP type flow director filter.\n\n"
@@ -738,14 +742,15 @@ static void cmd_help_long_parsed(void *parsed_result,
"fld-8th|none) (select|add)\n"
"Set the input set for hash.\n\n"

-   "set_fdir_input_set (port_id) (ipv4|ipv4-frag|"
-   "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
+   "set_fdir_input_set (port_id) "
+   "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
"ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
-   "l2_payload) (src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
-   "udp-src-port|udp-dst-port|tcp-src-port|tcp-dst-port|"
-   "sctp-src-port|sctp-dst-port|sctp-veri-tag|fld-1st|"
-   "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
-   "fld-8th|none) (select|add)\n"
+   "l2_payload) (ethertype|src-ipv4|dst-ipv4|src-ipv6|"
+   "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
+   "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
+   "udp-dst-port|tcp-src-port|tcp-dst-port|"
+   "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
+   " (select|add)\n"
"Set the input set for FDir.\n\n"
);
}
@@ -7983,6 +7988,12 @@ struct cmd_flow_director_result {
uint16_t port_dst;
cmdline_fixed_string_t verify_tag;
uint32_t verify_tag_value;
+   cmdline_ipaddr_t tos;
+   uint8_t tos_value;
+   cmdline_ipaddr_t proto;
+   uint8_t proto_value;
+   cmdline_ipaddr_t ttl;
+   uint8_t ttl_value;
cmdline_fixed_string_t vlan;
uint16_t vlan_value;
cmdline_fixed_string_t flexbytes;
@@ -8162,12 +8173,15 @@ cmd_flow_director_filter_parsed(void *parsed_result,
switch (entry.input.flow_type) {
case RTE_ETH_FLOW_FRAG_IPV4:
case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
+   entry.input.flow.ip4_flow.proto = res->proto_value;
case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
IPV4_ADDR_TO_UINT(res->ip_dst,
entry.input.flow.ip4_flow.dst_ip);
IPV4_ADDR_TO_UINT(res->ip_src,
entry.input.flow.ip4_flow.src_ip);
+   entry.input.flow.ip4_flow.tos = res->tos_value;
+   entry.input.flow.ip4_flow.ttl = res->ttl_value;
/* need convert to big endian. */
entry.input.flow.udp4_flow.dst_port =
 

[dpdk-dev] [PATCH 3/4] i40e: extend flow director to filter by more IP Header fields

2015-12-25 Thread Jingjing Wu
This patch extended flow director to select more IP Header fields
as filter input set.

Signed-off-by: Jingjing Wu 
---
 drivers/net/i40e/i40e_ethdev.c | 69 ++
 drivers/net/i40e/i40e_fdir.c   | 26 +++-
 2 files changed, 75 insertions(+), 20 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index b919aac..290776e 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -218,6 +218,8 @@
 #define I40E_REG_INSET_L3_IP4_TOS0x0040ULL
 /* IPv4 Protocol */
 #define I40E_REG_INSET_L3_IP4_PROTO  0x0004ULL
+/* IPv4 Time to Live */
+#define I40E_REG_INSET_L3_IP4_TTL0x0004ULL
 /* Source IPv6 address */
 #define I40E_REG_INSET_L3_SRC_IP60x0007F800ULL
 /* Destination IPv6 address */
@@ -226,6 +228,8 @@
 #define I40E_REG_INSET_L3_IP6_TC 0x0040ULL
 /* IPv6 Next Header */
 #define I40E_REG_INSET_L3_IP6_NEXT_HDR   0x0008ULL
+/* IPv6 Hop Limitr */
+#define I40E_REG_INSET_L3_IP6_HOP_LIMIT  0x0008ULL
 /* Source L4 port */
 #define I40E_REG_INSET_L4_SRC_PORT   0x0004ULL
 /* Destination L4 port */
@@ -269,10 +273,12 @@
 #define I40E_TRANSLATE_INSET 0
 #define I40E_TRANSLATE_REG   1

-#define I40E_INSET_IPV4_TOS_MASK  0x0009FF00UL
-#define I40E_INSET_IPV4_PROTO_MASK0x000DFF00UL
-#define I40E_INSET_IPV6_TC_MASK   0x0009F00FUL
-#define I40E_INSET_IPV6_NEXT_HDR_MASK 0x000C00FFUL
+#define I40E_INSET_IPV4_TOS_MASK0x0009FF00UL
+#define I40E_INSET_IPv4_TTL_MASK0x000D00FFUL
+#define I40E_INSET_IPV4_PROTO_MASK  0x000DFF00UL
+#define I40E_INSET_IPV6_TC_MASK 0x0009F00FUL
+#define I40E_INSET_IPV6_HOP_LIMIT_MASK  0x000CFF00UL
+#define I40E_INSET_IPV6_NEXT_HDR_MASK   0x000C00FFUL

 static int eth_i40e_dev_init(struct rte_eth_dev *eth_dev);
 static int eth_i40e_dev_uninit(struct rte_eth_dev *eth_dev);
@@ -6549,30 +6555,47 @@ i40e_get_valid_input_set(enum i40e_filter_pctype pctype,
 */
static const uint64_t valid_fdir_inset_table[] = {
[I40E_FILTER_PCTYPE_FRAG_IPV4] =
-   I40E_INSET_IPV4_SRC | I40E_INSET_IPV4_DST,
+   I40E_INSET_IPV4_SRC | I40E_INSET_IPV4_DST |
+   I40E_INSET_IPV4_TOS | I40E_INSET_IPV4_PROTO |
+   I40E_INSET_IPV4_TTL,
[I40E_FILTER_PCTYPE_NONF_IPV4_UDP] =
I40E_INSET_IPV4_SRC | I40E_INSET_IPV4_DST |
+   I40E_INSET_IPV4_TOS | I40E_INSET_IPV4_TTL |
I40E_INSET_SRC_PORT | I40E_INSET_DST_PORT,
[I40E_FILTER_PCTYPE_NONF_IPV4_TCP] =
-   I40E_INSET_IPV4_SRC | I40E_INSET_IPV4_DST,
+   I40E_INSET_IPV4_SRC | I40E_INSET_IPV4_DST |
+   I40E_INSET_IPV4_TOS | I40E_INSET_IPV4_TTL |
+   I40E_INSET_SRC_PORT | I40E_INSET_DST_PORT,
[I40E_FILTER_PCTYPE_NONF_IPV4_SCTP] =
I40E_INSET_IPV4_SRC | I40E_INSET_IPV4_DST |
+   I40E_INSET_IPV4_TOS | I40E_INSET_IPV4_TTL |
I40E_INSET_SRC_PORT | I40E_INSET_DST_PORT |
I40E_INSET_SCTP_VT,
[I40E_FILTER_PCTYPE_NONF_IPV4_OTHER] =
-   I40E_INSET_IPV4_SRC | I40E_INSET_IPV4_DST,
+   I40E_INSET_IPV4_SRC | I40E_INSET_IPV4_DST |
+   I40E_INSET_IPV4_TOS | I40E_INSET_IPV4_PROTO |
+   I40E_INSET_IPV4_TTL,
[I40E_FILTER_PCTYPE_FRAG_IPV6] =
-   I40E_INSET_IPV6_SRC | I40E_INSET_IPV6_DST,
+   I40E_INSET_IPV6_SRC | I40E_INSET_IPV6_DST |
+   I40E_INSET_IPV6_TC | I40E_INSET_IPV6_NEXT_HDR |
+   I40E_INSET_IPV6_HOP_LIMIT,
[I40E_FILTER_PCTYPE_NONF_IPV6_UDP] =
-   I40E_INSET_IPV6_SRC | I40E_INSET_IPV6_DST,
+   I40E_INSET_IPV6_SRC | I40E_INSET_IPV6_DST |
+   I40E_INSET_IPV6_TC | I40E_INSET_IPV6_HOP_LIMIT |
+   I40E_INSET_SRC_PORT | I40E_INSET_DST_PORT,
[I40E_FILTER_PCTYPE_NONF_IPV6_TCP] =
-   I40E_INSET_IPV6_SRC | I40E_INSET_IPV6_DST,
+   I40E_INSET_IPV6_SRC | I40E_INSET_IPV6_DST |
+   I40E_INSET_IPV6_TC | I40E_INSET_IPV6_HOP_LIMIT |
+   I40E_INSET_SRC_PORT | I40E_INSET_DST_PORT,
[I40E_FILTER_PCTYPE_NONF_IPV6_SCTP] =
I40E_INSET_IPV6_SRC | I40E_INSET_IPV6_DST |
+   I40E_INSET_IPV6_TC | I40E_INSET_IPV6_HOP_LIMIT |
I40E_INSET_SRC_PORT | I40E_INSET_DST_PORT |
I40E_INSET_SCTP_VT,
[I40E_FILTER_PCTYPE_NONF_IPV6_OTHER] =
-   I40E_INSET_IPV6_SRC | I40E_INSET_IPV6_DST,
+   I40E_INSET_IPV6_SRC | I40E_INSET_IPV6_DST |
+   I40E_INSET_IPV6_TC | I40E_INSET_IPV6_NEXT_HDR |
+   I40E_INSET_IPV6_HOP_LIMIT,

[dpdk-dev] [PATCH 2/4] i40e: split function for input set change of hash and fdir

2015-12-25 Thread Jingjing Wu
This patch splited function for input set change of hash and fdir,
and added a new function to set the input set to default when
initialization.

Signed-off-by: Jingjing Wu 
---
 drivers/net/i40e/i40e_ethdev.c | 330 +
 drivers/net/i40e/i40e_ethdev.h |  11 +-
 drivers/net/i40e/i40e_fdir.c   |   5 +-
 3 files changed, 180 insertions(+), 166 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index bf6220d..b919aac 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -262,7 +262,8 @@
 #define I40E_REG_INSET_FLEX_PAYLOAD_WORD70x0080ULL
 /* 8th word of flex payload */
 #define I40E_REG_INSET_FLEX_PAYLOAD_WORD80x0040ULL
-
+/* all 8 words flex payload */
+#define I40E_REG_INSET_FLEX_PAYLOAD_WORDS0x3FC0ULL
 #define I40E_REG_INSET_MASK_DEFAULT  0xULL

 #define I40E_TRANSLATE_INSET 0
@@ -373,6 +374,7 @@ static int i40e_dev_udp_tunnel_add(struct rte_eth_dev *dev,
struct rte_eth_udp_tunnel *udp_tunnel);
 static int i40e_dev_udp_tunnel_del(struct rte_eth_dev *dev,
struct rte_eth_udp_tunnel *udp_tunnel);
+static void i40e_filter_input_set_init(struct i40e_pf *pf);
 static int i40e_ethertype_filter_set(struct i40e_pf *pf,
struct rte_eth_ethertype_filter *filter,
bool add);
@@ -787,6 +789,8 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)
 * It should be removed once issues are fixed in NVM.
 */
i40e_flex_payload_reg_init(hw);
+   /* Initialize the input set for filters (hash and fd) to default value 
*/
+   i40e_filter_input_set_init(pf);

/* Initialize the parameters for adminq */
i40e_init_adminq_parameter(hw);
@@ -6545,43 +6549,32 @@ i40e_get_valid_input_set(enum i40e_filter_pctype pctype,
 */
static const uint64_t valid_fdir_inset_table[] = {
[I40E_FILTER_PCTYPE_FRAG_IPV4] =
-   I40E_INSET_IPV4_SRC | I40E_INSET_IPV4_DST |
-   I40E_INSET_FLEX_PAYLOAD,
+   I40E_INSET_IPV4_SRC | I40E_INSET_IPV4_DST,
[I40E_FILTER_PCTYPE_NONF_IPV4_UDP] =
I40E_INSET_IPV4_SRC | I40E_INSET_IPV4_DST |
-   I40E_INSET_SRC_PORT | I40E_INSET_DST_PORT |
-   I40E_INSET_FLEX_PAYLOAD,
+   I40E_INSET_SRC_PORT | I40E_INSET_DST_PORT,
[I40E_FILTER_PCTYPE_NONF_IPV4_TCP] =
-   I40E_INSET_IPV4_SRC | I40E_INSET_IPV4_DST |
-   I40E_INSET_SRC_PORT | I40E_INSET_DST_PORT |
-   I40E_INSET_FLEX_PAYLOAD,
+   I40E_INSET_IPV4_SRC | I40E_INSET_IPV4_DST,
[I40E_FILTER_PCTYPE_NONF_IPV4_SCTP] =
I40E_INSET_IPV4_SRC | I40E_INSET_IPV4_DST |
I40E_INSET_SRC_PORT | I40E_INSET_DST_PORT |
-   I40E_INSET_SCTP_VT | I40E_INSET_FLEX_PAYLOAD,
+   I40E_INSET_SCTP_VT,
[I40E_FILTER_PCTYPE_NONF_IPV4_OTHER] =
-   I40E_INSET_IPV4_SRC | I40E_INSET_IPV4_DST |
-   I40E_INSET_FLEX_PAYLOAD,
+   I40E_INSET_IPV4_SRC | I40E_INSET_IPV4_DST,
[I40E_FILTER_PCTYPE_FRAG_IPV6] =
-   I40E_INSET_IPV6_SRC | I40E_INSET_IPV6_DST |
-   I40E_INSET_FLEX_PAYLOAD,
+   I40E_INSET_IPV6_SRC | I40E_INSET_IPV6_DST,
[I40E_FILTER_PCTYPE_NONF_IPV6_UDP] =
-   I40E_INSET_IPV6_SRC | I40E_INSET_IPV6_DST |
-   I40E_INSET_SRC_PORT | I40E_INSET_DST_PORT |
-   I40E_INSET_FLEX_PAYLOAD,
+   I40E_INSET_IPV6_SRC | I40E_INSET_IPV6_DST,
[I40E_FILTER_PCTYPE_NONF_IPV6_TCP] =
-   I40E_INSET_IPV6_SRC | I40E_INSET_IPV6_DST |
-   I40E_INSET_SRC_PORT | I40E_INSET_DST_PORT |
-   I40E_INSET_FLEX_PAYLOAD,
+   I40E_INSET_IPV6_SRC | I40E_INSET_IPV6_DST,
[I40E_FILTER_PCTYPE_NONF_IPV6_SCTP] =
I40E_INSET_IPV6_SRC | I40E_INSET_IPV6_DST |
I40E_INSET_SRC_PORT | I40E_INSET_DST_PORT |
-   I40E_INSET_SCTP_VT | I40E_INSET_FLEX_PAYLOAD,
+   I40E_INSET_SCTP_VT,
[I40E_FILTER_PCTYPE_NONF_IPV6_OTHER] =
-   I40E_INSET_IPV6_SRC | I40E_INSET_IPV6_DST |
-   I40E_INSET_FLEX_PAYLOAD,
+   I40E_INSET_IPV6_SRC | I40E_INSET_IPV6_DST,
[I40E_FILTER_PCTYPE_L2_PAYLOAD] =
-   I40E_INSET_LAST_ETHER_TYPE | I40E_INSET_FLEX_PAYLOAD,
+   I40E_INSET_LAST_ETHER_TYPE,
};

if (pctype > I40E_FILTER_PCTYPE_L2_PAYLOAD)
@@ -6809,7 +6802,7 @@ i40e_translate_input_set_reg(uint64_t input)
return val;
 }

-static uint8_t
+static int
 i40e_generate_inset_mask_reg(uint64_t inset, uint32_t *mask, uint8_t nb_elem)
 {
uint8_t i, idx = 0;
@@ -6827,16 +6820,13 @@ 

[dpdk-dev] [PATCH 1/4] ethdev: extend flow director to support input set selection

2015-12-25 Thread Jingjing Wu
This patch add RTE_ETH_INPUT_SET_L3_IP4_TTL,
RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS input field type and extends
struct rte_eth_ipv4_flow and rte_eth_ipv6_flow to support filtering
by tos, protocol and ttl.

Signed-off-by: Jingjing Wu 
---
 lib/librte_ether/rte_eth_ctrl.h | 8 
 1 file changed, 8 insertions(+)

diff --git a/lib/librte_ether/rte_eth_ctrl.h b/lib/librte_ether/rte_eth_ctrl.h
index ce224ad..248f719 100644
--- a/lib/librte_ether/rte_eth_ctrl.h
+++ b/lib/librte_ether/rte_eth_ctrl.h
@@ -337,9 +337,11 @@ enum rte_eth_input_set_field {
RTE_ETH_INPUT_SET_L3_SRC_IP6,
RTE_ETH_INPUT_SET_L3_DST_IP6,
RTE_ETH_INPUT_SET_L3_IP4_TOS,
+   RTE_ETH_INPUT_SET_L3_IP4_TTL,
RTE_ETH_INPUT_SET_L3_IP4_PROTO,
RTE_ETH_INPUT_SET_L3_IP6_TC,
RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER,
+   RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS,

/* L4 */
RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT = 257,
@@ -407,6 +409,9 @@ struct rte_eth_l2_flow {
 struct rte_eth_ipv4_flow {
uint32_t src_ip;  /**< IPv4 source address to match. */
uint32_t dst_ip;  /**< IPv4 destination address to match. */
+   uint8_t  tos; /**< Type of service to match. */
+   uint8_t  ttl; /**< Time to live */
+   uint8_t  proto;
 };

 /**
@@ -443,6 +448,9 @@ struct rte_eth_sctpv4_flow {
 struct rte_eth_ipv6_flow {
uint32_t src_ip[4];  /**< IPv6 source address to match. */
uint32_t dst_ip[4];  /**< IPv6 destination address to match. */
+   uint8_t  tc; /**< Traffic class to match. */
+   uint8_t  proto;  /**< Protocol, next header. */
+   uint8_t  hop_limits;
 };

 /**
-- 
2.4.0



[dpdk-dev] [PATCH 0/4] extend flow director's IP fields in i40e driver

2015-12-25 Thread Jingjing Wu
This patch set extends flow director to support filtering by TOS,
Protocol and TTL in i40e driver.

Jingjing Wu (4):
  ethdev: extend flow director to support input set selection
  i40e: split function for input set change of hash and fdir
  i40e: extend flow director to filter by more IP Header fields
  testpmd: extend commands for filter's input set changing

 app/test-pmd/cmdline.c  | 100 ++--
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  34 +--
 drivers/net/i40e/i40e_ethdev.c  | 367 
 drivers/net/i40e/i40e_ethdev.h  |  11 +-
 drivers/net/i40e/i40e_fdir.c|  31 ++-
 lib/librte_ether/rte_eth_ctrl.h |   8 +
 6 files changed, 344 insertions(+), 207 deletions(-)

-- 
2.4.0



[dpdk-dev] [PATCH 3/3] examples/l3fwd: Handle SIGINT and SIGTERM in l3fwd

2015-12-25 Thread Wang, Zhihong
> On Wed, 23 Dec 2015 15:03:15 -0500
> Zhihong Wang  wrote:
> 
> > +/* When we receive a INT signal, close all ports */ static void
> > +sigint_handler(__rte_unused int signum) {
> > +   unsigned portid, nb_ports;
> > +
> > +   printf("Preparing to exit...\n");
> > +   nb_ports = rte_eth_dev_count();
> > +   for (portid = 0; portid < nb_ports; portid++) {
> > +   if ((enabled_port_mask & (1 << portid)) == 0) {
> > +   continue;
> > +   }
> > +   printf("Stopping port %d...", portid);
> > +   rte_eth_dev_stop(portid);
> > +   rte_eth_dev_close(portid);
> > +   printf(" Done\n");
> > +   }
> > +   printf("Bye...\n");
> > +   exit(0);
> > +}
> 
> Signal handlers should only set a flag, which is then checked by thread loops.
> Calling functions in DPDK from signal handlers is not safe.

I'll make changes in v2 to address this issue. Thanks for pointing out :)
In some cases signal handler have to do the exit though, like when the program 
is still doing memory initialization and will take some time.


[dpdk-dev] [PATCH 3/3] examples/l3fwd: Handle SIGINT and SIGTERM in l3fwd

2015-12-25 Thread Wang, Zhihong
> > +/* When we receive a INT signal, close all ports */ static void
> > +sigint_handler(__rte_unused int signum) {
> > +   unsigned portid, nb_ports;
> > +
> > +   printf("Preparing to exit...\n");
> > +   nb_ports = rte_eth_dev_count();
> > +   for (portid = 0; portid < nb_ports; portid++) {
> > +   if ((enabled_port_mask & (1 << portid)) == 0) {
> > +   continue;
> > +   }
> > +   printf("Stopping port %d...", portid);
> > +   rte_eth_dev_stop(portid);
> > +   rte_eth_dev_close(portid);
> 
> Hmm, so your interrupt thread invokes dev_stop, while IO lcores keep calling
> rx_burst/tx_burst?
> For graceful shutdown on SIGINT, I suppose you first have to stop your IO 
> lcores
> first.
> Let say have a global var: 'stop' that every lcore has to check from time to 
> time (or
> something similar).

Thanks for the advice! This works once the program enters the forwarding phase.
Have to go the other way if it's still in initialization phase which can take 
quite some time.

/Zhihong

> Konstantin
> 
> > +   printf(" Done\n");
> > +   }
> > +   printf("Bye...\n");
> > +   exit(0);
> > +}
> > +
> >  int
> >  main(int argc, char **argv)
> >  {
> > @@ -2572,6 +2594,9 @@ main(int argc, char **argv)
> > uint32_t n_tx_queue, nb_lcores;
> > uint8_t portid, nb_rx_queue, queue, socketid;
> >
> > +   signal(SIGINT, sigint_handler);
> > +   signal(SIGTERM, sigint_handler);
> > +
> > /* init EAL */
> > ret = rte_eal_init(argc, argv);
> > if (ret < 0)
> > --
> > 2.5.0



[dpdk-dev] [PATCH 4/4] virtio: check if any kernel driver is manipulating the device

2015-12-25 Thread Huawei Xie
virtio PMD could use IO port to configure the virtio device without
using uio driver.

There are two issues with previous implementation:
1) virtio PMD will take over each virtio device blindly even if some
are not intended for DPDK.
2) driver conflict between virtio PMD and virtio-net kernel driver.

This patch checks if there is any kernel driver manipulating the virtio
device before virtio PMD uses IO port to configure the device.

Fixes: da978dfdc43b ("virtio: use port IO to get PCI resource")

Signed-off-by: Huawei Xie 
---
 drivers/net/virtio/virtio_ethdev.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/net/virtio/virtio_ethdev.c 
b/drivers/net/virtio/virtio_ethdev.c
index 00015ef..504346a 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -1138,6 +1138,13 @@ static int virtio_resource_init_by_ioports(struct 
rte_pci_device *pci_dev)
int found = 0;
size_t linesz;

+   if (pci_dev->kdrv != RTE_KDRV_NONE) {
+   PMD_INIT_LOG(ERR,
+   "%s(): kernel driver is manipulating this device." \
+   " Please unbind the kernel driver.", __func__);
+   return -1;
+   }
+
snprintf(pci_id, sizeof(pci_id), PCI_PRI_FMT,
 pci_dev->addr.domain,
 pci_dev->addr.bus,
-- 
1.8.1.4



[dpdk-dev] [PATCH 2/4] eal: set kdrv to RTE_KDRV_NONE if kernel driver isn't manipulating the device.

2015-12-25 Thread Huawei Xie
Use RTE_KDRV_NONE to indicate that kernel driver isn't manipulating the
device.

Signed-off-by: Huawei Xie 
---
 lib/librte_eal/linuxapp/eal/eal_pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c 
b/lib/librte_eal/linuxapp/eal/eal_pci.c
index bc5b5be..640b190 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
@@ -362,7 +362,7 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t 
bus,
else
dev->kdrv = RTE_KDRV_UNKNOWN;
} else
-   dev->kdrv = RTE_KDRV_UNKNOWN;
+   dev->kdrv = RTE_KDRV_NONE;

/* device is valid, add in list (sorted) */
if (TAILQ_EMPTY(_device_list)) {
-- 
1.8.1.4



[dpdk-dev] [PATCH 1/4] eal: make the comment more accurate

2015-12-25 Thread Huawei Xie

Signed-off-by: Huawei Xie 
---
 lib/librte_eal/common/eal_common_pci.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_pci.c 
b/lib/librte_eal/common/eal_common_pci.c
index dcfe947..bbcdb2b 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -204,7 +204,7 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, 
struct rte_pci_device *d
/* call the driver devinit() function */
return dr->devinit(dr, dev);
}
-   /* return positive value if driver is not found */
+   /* return positive value if driver doesn't support this device */
return 1;
 }

@@ -259,7 +259,7 @@ rte_eal_pci_detach_dev(struct rte_pci_driver *dr,
return 0;
}

-   /* return positive value if driver is not found */
+   /* return positive value if driver doesn't support this device */
return 1;
 }

@@ -283,7 +283,7 @@ pci_probe_all_drivers(struct rte_pci_device *dev)
/* negative value is an error */
return -1;
if (rc > 0)
-   /* positive value means driver not found */
+   /* positive value means driver doesn't support it */
continue;
return 0;
}
@@ -310,7 +310,7 @@ pci_detach_all_drivers(struct rte_pci_device *dev)
/* negative value is an error */
return -1;
if (rc > 0)
-   /* positive value means driver not found */
+   /* positive value means driver doesn't support it */
continue;
return 0;
}
-- 
1.8.1.4



[dpdk-dev] [PATCH 0/4] check if any kernel driver is manipulating the virtio device

2015-12-25 Thread Huawei Xie
virtio PMD doesn't set RTE_PCI_DRV_NEED_MAPPING in drv_flags of its
eth_driver. It will try igb_uio and PORT IO in turn to configure
virtio device. Even user in guest VM doesn't want to use virtio for
DPDK, virtio PMD will take over the device blindly.

The more serious problem is kernel driver is still manipulating the
device, which causes driver conflict.

This patch checks if there is any kernel driver manipulating the
virtio device before virtio PMD uses port IO to configure the device.

Huawei Xie (4):
  eal: make the comment more accurate
  eal: set kdrv to RTE_KDRV_NONE if kernel driver isn't manipulating the device.
  virtio: return 1 to tell the kernel we don't take over this device
  virtio: check if any kernel driver is manipulating the virtio device

 drivers/net/virtio/virtio_ethdev.c | 15 +--
 lib/librte_eal/common/eal_common_pci.c |  8 
 lib/librte_eal/linuxapp/eal/eal_pci.c  |  2 +-
 3 files changed, 18 insertions(+), 7 deletions(-)

-- 
1.8.1.4