X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=examples%2Fip_pipeline%2Flink.c;h=16bcffe356bcb2a06288484168403ec4f35260c5;hb=3ee6f706519c0a7456f3d8a79048150dfa6d2581;hp=26ff41ba9c9bb81a95dc55d641555c42b4e1dfa5;hpb=133c2c6565d6d05432be2e2bafc0e08ef0fd9221;p=dpdk.git diff --git a/examples/ip_pipeline/link.c b/examples/ip_pipeline/link.c index 26ff41ba9c..16bcffe356 100644 --- a/examples/ip_pipeline/link.c +++ b/examples/ip_pipeline/link.c @@ -6,6 +6,7 @@ #include #include +#include #include "link.h" #include "mempool.h" @@ -35,20 +36,16 @@ link_find(const char *name) return NULL; } +struct link * +link_next(struct link *link) +{ + return (link == NULL) ? TAILQ_FIRST(&link_list) : TAILQ_NEXT(link, node); +} + static struct rte_eth_conf port_conf_default = { .link_speeds = 0, .rxmode = { .mq_mode = ETH_MQ_RX_NONE, - - .header_split = 0, /* Header split */ - .hw_ip_checksum = 0, /* IP checksum offload */ - .hw_vlan_filter = 0, /* VLAN filtering */ - .hw_vlan_strip = 0, /* VLAN strip */ - .hw_vlan_extend = 0, /* Extended VLAN */ - .jumbo_frame = 0, /* Jumbo frame support */ - .hw_strip_crc = 1, /* CRC strip by HW */ - .enable_scatter = 0, /* Scattered packets RX handler */ - .max_rx_pkt_len = 9000, /* Jumbo frame max packet len */ .split_hdr_size = 0, /* Header split buffer size */ }, @@ -132,7 +129,8 @@ link_create(const char *name, struct link_params *params) if (!rte_eth_dev_is_valid_port(port_id)) return NULL; - rte_eth_dev_info_get(port_id, &port_info); + if (rte_eth_dev_info_get(port_id, &port_info) != 0) + return NULL; mempool = mempool_find(params->rx.mempool_name); if (mempool == NULL) @@ -161,7 +159,8 @@ link_create(const char *name, struct link_params *params) if (rss) { port_conf.rxmode.mq_mode = ETH_MQ_RX_RSS; port_conf.rx_adv_conf.rss_conf.rss_hf = - ETH_RSS_IPV4 | ETH_RSS_IPV6; + (ETH_RSS_IP | ETH_RSS_TCP | ETH_RSS_UDP) & + port_info.flow_type_rss_offloads; } cpu_id = (uint32_t) rte_eth_dev_socket_id(port_id); @@ -177,8 +176,11 @@ link_create(const char *name, struct link_params *params) if (status < 0) return NULL; - if (params->promiscuous) - rte_eth_promiscuous_enable(port_id); + if (params->promiscuous) { + status = rte_eth_promiscuous_enable(port_id); + if (status != 0) + return NULL; + } /* Port RX */ for (i = 0; i < params->rx.n_queues; i++) { @@ -236,7 +238,7 @@ link_create(const char *name, struct link_params *params) } /* Node fill in */ - strncpy(link->name, name, sizeof(link->name)); + strlcpy(link->name, name, sizeof(link->name)); link->port_id = port_id; link->n_rxq = params->rx.n_queues; link->n_txq = params->tx.n_queues; @@ -262,7 +264,8 @@ link_is_up(const char *name) return 0; /* Resource */ - rte_eth_link_get(link->port_id, &link_params); + if (rte_eth_link_get(link->port_id, &link_params) < 0) + return 0; return (link_params.link_status == ETH_LINK_DOWN) ? 0 : 1; }