* [dpdk-dev] [PATCH 1/4] app/pdump: fix duplicate macro definition
2017-02-21 16:52 [dpdk-dev] [PATCH 0/4] minor fixes and cleanup Bruce Richardson
@ 2017-02-21 16:52 ` Bruce Richardson
2017-02-21 16:52 ` [dpdk-dev] [PATCH 2/4] ring: add a function to return the ring size Bruce Richardson
` (8 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Bruce Richardson @ 2017-02-21 16:52 UTC (permalink / raw)
To: dev; +Cc: Bruce Richardson
RTE_RING_SZ_MASK is redefined here with the original definition in
rte_ring.h. Since rte_ring.h is already included, just remove the
duplicate definition here.
Fixes: caa7028276b8 ("app/pdump: add tool for packet capturing")
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
app/pdump/main.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/app/pdump/main.c b/app/pdump/main.c
index f3ef181..b88090d 100644
--- a/app/pdump/main.c
+++ b/app/pdump/main.c
@@ -92,7 +92,6 @@
#define BURST_SIZE 32
#define NUM_VDEVS 2
-#define RTE_RING_SZ_MASK (unsigned)(0x0fffffff) /**< Ring size mask */
/* true if x is a power of 2 */
#define POWEROF2(x) ((((x)-1) & (x)) == 0)
--
2.9.3
^ permalink raw reply [flat|nested] 15+ messages in thread
* [dpdk-dev] [PATCH 2/4] ring: add a function to return the ring size
2017-02-21 16:52 [dpdk-dev] [PATCH 0/4] minor fixes and cleanup Bruce Richardson
2017-02-21 16:52 ` [dpdk-dev] [PATCH 1/4] app/pdump: fix duplicate macro definition Bruce Richardson
@ 2017-02-21 16:52 ` Bruce Richardson
2017-02-21 16:52 ` [dpdk-dev] [PATCH 3/4] crypto/null: use ring size function Bruce Richardson
` (7 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Bruce Richardson @ 2017-02-21 16:52 UTC (permalink / raw)
To: dev; +Cc: Bruce Richardson
Applications and other libraries should not be reading inside the
rte_ring structure directly to get the ring size. Instead add a fn
to allow it to be queried.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
lib/librte_ring/rte_ring.h | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/lib/librte_ring/rte_ring.h b/lib/librte_ring/rte_ring.h
index e359aff..72ccca5 100644
--- a/lib/librte_ring/rte_ring.h
+++ b/lib/librte_ring/rte_ring.h
@@ -1108,6 +1108,20 @@ rte_ring_free_count(const struct rte_ring *r)
}
/**
+ * Return the size of the ring.
+ *
+ * @param r
+ * A pointer to the ring structure.
+ * @return
+ * The number of elements which can be stored in the ring.
+ */
+static inline unsigned int
+rte_ring_get_size(const struct rte_ring *r)
+{
+ return r->prod.size;
+}
+
+/**
* Dump the status of all rings on the console
*
* @param f
--
2.9.3
^ permalink raw reply [flat|nested] 15+ messages in thread
* [dpdk-dev] [PATCH 3/4] crypto/null: use ring size function
2017-02-21 16:52 [dpdk-dev] [PATCH 0/4] minor fixes and cleanup Bruce Richardson
2017-02-21 16:52 ` [dpdk-dev] [PATCH 1/4] app/pdump: fix duplicate macro definition Bruce Richardson
2017-02-21 16:52 ` [dpdk-dev] [PATCH 2/4] ring: add a function to return the ring size Bruce Richardson
@ 2017-02-21 16:52 ` Bruce Richardson
2017-02-21 16:52 ` [dpdk-dev] [PATCH 4/4] examples/quota_watermark: correct code indentation Bruce Richardson
` (6 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Bruce Richardson @ 2017-02-21 16:52 UTC (permalink / raw)
To: dev; +Cc: Bruce Richardson
Rather than reading the size directly from the ring structure,
use the dedicated function for that purpose.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
drivers/crypto/null/null_crypto_pmd_ops.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/crypto/null/null_crypto_pmd_ops.c b/drivers/crypto/null/null_crypto_pmd_ops.c
index 26ff631..4a24537 100644
--- a/drivers/crypto/null/null_crypto_pmd_ops.c
+++ b/drivers/crypto/null/null_crypto_pmd_ops.c
@@ -193,7 +193,7 @@ null_crypto_pmd_qp_create_processed_pkts_ring(struct null_crypto_qp *qp,
r = rte_ring_lookup(qp->name);
if (r) {
- if (r->prod.size >= ring_size) {
+ if (rte_ring_get_size(r) >= ring_size) {
NULL_CRYPTO_LOG_INFO(
"Reusing existing ring %s for processed packets",
qp->name);
--
2.9.3
^ permalink raw reply [flat|nested] 15+ messages in thread
* [dpdk-dev] [PATCH 4/4] examples/quota_watermark: correct code indentation
2017-02-21 16:52 [dpdk-dev] [PATCH 0/4] minor fixes and cleanup Bruce Richardson
` (2 preceding siblings ...)
2017-02-21 16:52 ` [dpdk-dev] [PATCH 3/4] crypto/null: use ring size function Bruce Richardson
@ 2017-02-21 16:52 ` Bruce Richardson
2017-02-23 16:41 ` [dpdk-dev] [PATCH v2 0/5] minor fixes and cleanup Bruce Richardson
` (5 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Bruce Richardson @ 2017-02-21 16:52 UTC (permalink / raw)
To: dev; +Cc: Bruce Richardson
The code indentation in the example app files used spaces rather than
tabs for indentation, and as such did not conform to DPDK conventions.
This left those modifying the code in a bind - to fix things on a line
by line basis so as to avoid checkpatch errors, or to keep things
consistent within the file, and accept checkpatch errors.
Since these files have not had too many changes since the original
import, there is little change history to lose by doing a complete
reformatting of the code, so just update all indentation to standard.
In the process, wrap long lines appropriately, avoiding splitting
error messages.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
examples/quota_watermark/qw/args.c | 63 ++---
examples/quota_watermark/qw/init.c | 177 +++++++-------
examples/quota_watermark/qw/main.c | 377 ++++++++++++++++--------------
examples/quota_watermark/qw/main.h | 6 +-
examples/quota_watermark/qwctl/commands.c | 208 +++++++++--------
examples/quota_watermark/qwctl/qwctl.c | 38 +--
6 files changed, 449 insertions(+), 420 deletions(-)
diff --git a/examples/quota_watermark/qw/args.c b/examples/quota_watermark/qw/args.c
index 408b54d..6ba77bc 100644
--- a/examples/quota_watermark/qw/args.c
+++ b/examples/quota_watermark/qw/args.c
@@ -47,9 +47,9 @@ unsigned int portmask = 0;
static void
usage(const char *prgname)
{
- fprintf(stderr, "Usage: %s [EAL args] -- -p <portmask>\n"
- "-p PORTMASK: hexadecimal bitmask of NIC ports to configure\n",
- prgname);
+ fprintf(stderr, "Usage: %s [EAL args] -- -p <portmask>\n"
+ "-p PORTMASK: hexadecimal bitmask of NIC ports to configure\n",
+ prgname);
}
static unsigned long
@@ -61,44 +61,47 @@ parse_portmask(const char *portmask_str)
static void
check_core_count(void)
{
- if (rte_lcore_count() < 3)
- rte_exit(EXIT_FAILURE, "At least 3 cores need to be passed in the coremask\n");
+ if (rte_lcore_count() < 3)
+ rte_exit(EXIT_FAILURE,
+ "At least 3 cores need to be passed in the coremask\n");
}
static void
check_portmask_value(unsigned int portmask)
{
- unsigned int port_nb = 0;
+ unsigned int port_nb = 0;
- port_nb = __builtin_popcount(portmask);
+ port_nb = __builtin_popcount(portmask);
- if (port_nb == 0)
- rte_exit(EXIT_FAILURE, "At least 2 ports need to be passed in the portmask\n");
+ if (port_nb == 0)
+ rte_exit(EXIT_FAILURE,
+ "At least 2 ports need to be passed in the portmask\n");
- if (port_nb % 2 != 0)
- rte_exit(EXIT_FAILURE, "An even number of ports is required in the portmask\n");
+ if (port_nb % 2 != 0)
+ rte_exit(EXIT_FAILURE,
+ "An even number of ports is required in the portmask\n");
}
int
parse_qw_args(int argc, char **argv)
{
- int opt;
-
- while ((opt = getopt(argc, argv, "h:p:")) != -1) {
- switch (opt) {
- case 'h':
- usage(argv[0]);
- break;
- case 'p':
- portmask = parse_portmask(optarg);
- break;
- default:
- usage(argv[0]);
- }
- }
-
- check_core_count();
- check_portmask_value(portmask);
-
- return 0;
+ int opt;
+
+ while ((opt = getopt(argc, argv, "h:p:")) != -1) {
+ switch (opt) {
+ case 'h':
+ usage(argv[0]);
+ break;
+ case 'p':
+ portmask = parse_portmask(optarg);
+ break;
+ default:
+ usage(argv[0]);
+ }
+ }
+
+ check_core_count();
+ check_portmask_value(portmask);
+
+ return 0;
}
diff --git a/examples/quota_watermark/qw/init.c b/examples/quota_watermark/qw/init.c
index c208721..e941ce8 100644
--- a/examples/quota_watermark/qw/init.c
+++ b/examples/quota_watermark/qw/init.c
@@ -51,124 +51,127 @@
static const struct rte_eth_conf port_conf = {
- .rxmode = {
- .split_hdr_size = 0,
- .header_split = 0, /**< Header Split disabled */
- .hw_ip_checksum = 0, /**< IP checksum offload disabled */
- .hw_vlan_filter = 0, /**< VLAN filtering disabled */
- .jumbo_frame = 0, /**< Jumbo Frame Support disabled */
- .hw_strip_crc = 0, /**< CRC stripped by hardware */
- },
- .txmode = {
- .mq_mode = ETH_DCB_NONE,
- },
+ .rxmode = {
+ .split_hdr_size = 0,
+ .header_split = 0, /**< Header Split disabled */
+ .hw_ip_checksum = 0, /**< IP csum offload disabled */
+ .hw_vlan_filter = 0, /**< VLAN filtering disabled */
+ .jumbo_frame = 0, /**< Jumbo Frame disabled */
+ .hw_strip_crc = 0, /**< CRC stripped by hardware */
+ },
+ .txmode = {
+ .mq_mode = ETH_DCB_NONE,
+ },
};
static struct rte_eth_fc_conf fc_conf = {
- .mode = RTE_FC_TX_PAUSE,
- .high_water = 80 * 510 / 100,
- .low_water = 60 * 510 / 100,
- .pause_time = 1337,
- .send_xon = 0,
+ .mode = RTE_FC_TX_PAUSE,
+ .high_water = 80 * 510 / 100,
+ .low_water = 60 * 510 / 100,
+ .pause_time = 1337,
+ .send_xon = 0,
};
void configure_eth_port(uint8_t port_id)
{
- int ret;
-
- rte_eth_dev_stop(port_id);
-
- ret = rte_eth_dev_configure(port_id, 1, 1, &port_conf);
- if (ret < 0)
- rte_exit(EXIT_FAILURE, "Cannot configure port %u (error %d)\n",
- (unsigned) port_id, ret);
-
- /* Initialize the port's RX queue */
- ret = rte_eth_rx_queue_setup(port_id, 0, RX_DESC_PER_QUEUE,
- rte_eth_dev_socket_id(port_id),
- NULL,
- mbuf_pool);
- if (ret < 0)
- rte_exit(EXIT_FAILURE, "Failed to setup RX queue on "
- "port %u (error %d)\n", (unsigned) port_id, ret);
-
- /* Initialize the port's TX queue */
- ret = rte_eth_tx_queue_setup(port_id, 0, TX_DESC_PER_QUEUE,
- rte_eth_dev_socket_id(port_id),
- NULL);
- if (ret < 0)
- rte_exit(EXIT_FAILURE, "Failed to setup TX queue on "
- "port %u (error %d)\n", (unsigned) port_id, ret);
-
- /* Initialize the port's flow control */
- ret = rte_eth_dev_flow_ctrl_set(port_id, &fc_conf);
- if (ret < 0)
- rte_exit(EXIT_FAILURE, "Failed to setup hardware flow control on "
- "port %u (error %d)\n", (unsigned) port_id, ret);
-
- /* Start the port */
- ret = rte_eth_dev_start(port_id);
- if (ret < 0)
- rte_exit(EXIT_FAILURE, "Failed to start port %u (error %d)\n",
- (unsigned) port_id, ret);
-
- /* Put it in promiscuous mode */
- rte_eth_promiscuous_enable(port_id);
+ int ret;
+
+ rte_eth_dev_stop(port_id);
+
+ ret = rte_eth_dev_configure(port_id, 1, 1, &port_conf);
+ if (ret < 0)
+ rte_exit(EXIT_FAILURE, "Cannot configure port %u (error %d)\n",
+ (unsigned int) port_id, ret);
+
+ /* Initialize the port's RX queue */
+ ret = rte_eth_rx_queue_setup(port_id, 0, RX_DESC_PER_QUEUE,
+ rte_eth_dev_socket_id(port_id),
+ NULL,
+ mbuf_pool);
+ if (ret < 0)
+ rte_exit(EXIT_FAILURE,
+ "Failed to setup RX queue on port %u (error %d)\n",
+ (unsigned int) port_id, ret);
+
+ /* Initialize the port's TX queue */
+ ret = rte_eth_tx_queue_setup(port_id, 0, TX_DESC_PER_QUEUE,
+ rte_eth_dev_socket_id(port_id),
+ NULL);
+ if (ret < 0)
+ rte_exit(EXIT_FAILURE,
+ "Failed to setup TX queue on port %u (error %d)\n",
+ (unsigned int) port_id, ret);
+
+ /* Initialize the port's flow control */
+ ret = rte_eth_dev_flow_ctrl_set(port_id, &fc_conf);
+ if (ret < 0)
+ rte_exit(EXIT_FAILURE,
+ "Failed to setup hardware flow control on port %u (error %d)\n",
+ (unsigned int) port_id, ret);
+
+ /* Start the port */
+ ret = rte_eth_dev_start(port_id);
+ if (ret < 0)
+ rte_exit(EXIT_FAILURE, "Failed to start port %u (error %d)\n",
+ (unsigned int) port_id, ret);
+
+ /* Put it in promiscuous mode */
+ rte_eth_promiscuous_enable(port_id);
}
void
init_dpdk(void)
{
- if (rte_eth_dev_count() < 2)
- rte_exit(EXIT_FAILURE, "Not enough ethernet port available\n");
+ if (rte_eth_dev_count() < 2)
+ rte_exit(EXIT_FAILURE, "Not enough ethernet port available\n");
}
void init_ring(int lcore_id, uint8_t port_id)
{
- struct rte_ring *ring;
- char ring_name[RTE_RING_NAMESIZE];
+ struct rte_ring *ring;
+ char ring_name[RTE_RING_NAMESIZE];
- snprintf(ring_name, RTE_RING_NAMESIZE,
- "core%d_port%d", lcore_id, port_id);
- ring = rte_ring_create(ring_name, RING_SIZE, rte_socket_id(),
- RING_F_SP_ENQ | RING_F_SC_DEQ);
+ snprintf(ring_name, RTE_RING_NAMESIZE,
+ "core%d_port%d", lcore_id, port_id);
+ ring = rte_ring_create(ring_name, RING_SIZE, rte_socket_id(),
+ RING_F_SP_ENQ | RING_F_SC_DEQ);
- if (ring == NULL)
- rte_exit(EXIT_FAILURE, "%s\n", rte_strerror(rte_errno));
+ if (ring == NULL)
+ rte_exit(EXIT_FAILURE, "%s\n", rte_strerror(rte_errno));
- rte_ring_set_water_mark(ring, 80 * RING_SIZE / 100);
+ rte_ring_set_water_mark(ring, 80 * RING_SIZE / 100);
- rings[lcore_id][port_id] = ring;
+ rings[lcore_id][port_id] = ring;
}
void
pair_ports(void)
{
- uint8_t i, j;
-
- /* Pair ports with their "closest neighbour" in the portmask */
- for (i = 0; i < RTE_MAX_ETHPORTS; i++)
- if (is_bit_set(i, portmask))
- for (j = (uint8_t) (i + 1); j < RTE_MAX_ETHPORTS; j++)
- if (is_bit_set(j, portmask)) {
- port_pairs[i] = j;
- port_pairs[j] = i;
- i = j;
- break;
- }
+ uint8_t i, j;
+
+ /* Pair ports with their "closest neighbour" in the portmask */
+ for (i = 0; i < RTE_MAX_ETHPORTS; i++)
+ if (is_bit_set(i, portmask))
+ for (j = (uint8_t) (i + 1); j < RTE_MAX_ETHPORTS; j++)
+ if (is_bit_set(j, portmask)) {
+ port_pairs[i] = j;
+ port_pairs[j] = i;
+ i = j;
+ break;
+ }
}
void
setup_shared_variables(void)
{
- const struct rte_memzone *qw_memzone;
+ const struct rte_memzone *qw_memzone;
- qw_memzone = rte_memzone_reserve(QUOTA_WATERMARK_MEMZONE_NAME, 2 * sizeof(int),
- rte_socket_id(), RTE_MEMZONE_2MB);
- if (qw_memzone == NULL)
- rte_exit(EXIT_FAILURE, "%s\n", rte_strerror(rte_errno));
+ qw_memzone = rte_memzone_reserve(QUOTA_WATERMARK_MEMZONE_NAME,
+ 2 * sizeof(int), rte_socket_id(), RTE_MEMZONE_2MB);
+ if (qw_memzone == NULL)
+ rte_exit(EXIT_FAILURE, "%s\n", rte_strerror(rte_errno));
- quota = qw_memzone->addr;
- low_watermark = (unsigned int *) qw_memzone->addr + 1;
+ quota = qw_memzone->addr;
+ low_watermark = (unsigned int *) qw_memzone->addr + 1;
}
diff --git a/examples/quota_watermark/qw/main.c b/examples/quota_watermark/qw/main.c
index 9162e28..57df8ef 100644
--- a/examples/quota_watermark/qw/main.c
+++ b/examples/quota_watermark/qw/main.c
@@ -60,8 +60,8 @@
#define ETHER_TYPE_FLOW_CONTROL 0x8808
struct ether_fc_frame {
- uint16_t opcode;
- uint16_t param;
+ uint16_t opcode;
+ uint16_t param;
} __attribute__((__packed__));
@@ -76,38 +76,39 @@ struct rte_mempool *mbuf_pool;
static void send_pause_frame(uint8_t port_id, uint16_t duration)
{
- struct rte_mbuf *mbuf;
- struct ether_fc_frame *pause_frame;
- struct ether_hdr *hdr;
- struct ether_addr mac_addr;
+ struct rte_mbuf *mbuf;
+ struct ether_fc_frame *pause_frame;
+ struct ether_hdr *hdr;
+ struct ether_addr mac_addr;
- RTE_LOG_DP(DEBUG, USER1, "Sending PAUSE frame (duration=%d) on port %d\n",
- duration, port_id);
+ RTE_LOG_DP(DEBUG, USER1,
+ "Sending PAUSE frame (duration=%d) on port %d\n",
+ duration, port_id);
- /* Get a mbuf from the pool */
- mbuf = rte_pktmbuf_alloc(mbuf_pool);
- if (unlikely(mbuf == NULL))
- return;
+ /* Get a mbuf from the pool */
+ mbuf = rte_pktmbuf_alloc(mbuf_pool);
+ if (unlikely(mbuf == NULL))
+ return;
- /* Prepare a PAUSE frame */
- hdr = rte_pktmbuf_mtod(mbuf, struct ether_hdr *);
- pause_frame = (struct ether_fc_frame *) &hdr[1];
+ /* Prepare a PAUSE frame */
+ hdr = rte_pktmbuf_mtod(mbuf, struct ether_hdr *);
+ pause_frame = (struct ether_fc_frame *) &hdr[1];
- rte_eth_macaddr_get(port_id, &mac_addr);
- ether_addr_copy(&mac_addr, &hdr->s_addr);
+ rte_eth_macaddr_get(port_id, &mac_addr);
+ ether_addr_copy(&mac_addr, &hdr->s_addr);
- void *tmp = &hdr->d_addr.addr_bytes[0];
- *((uint64_t *)tmp) = 0x010000C28001ULL;
+ void *tmp = &hdr->d_addr.addr_bytes[0];
+ *((uint64_t *)tmp) = 0x010000C28001ULL;
- hdr->ether_type = rte_cpu_to_be_16(ETHER_TYPE_FLOW_CONTROL);
+ hdr->ether_type = rte_cpu_to_be_16(ETHER_TYPE_FLOW_CONTROL);
- pause_frame->opcode = rte_cpu_to_be_16(0x0001);
- pause_frame->param = rte_cpu_to_be_16(duration);
+ pause_frame->opcode = rte_cpu_to_be_16(0x0001);
+ pause_frame->param = rte_cpu_to_be_16(duration);
- mbuf->pkt_len = 60;
- mbuf->data_len = 60;
+ mbuf->pkt_len = 60;
+ mbuf->data_len = 60;
- rte_eth_tx_burst(port_id, 0, &mbuf, 1);
+ rte_eth_tx_burst(port_id, 0, &mbuf, 1);
}
/**
@@ -121,13 +122,13 @@ static void send_pause_frame(uint8_t port_id, uint16_t duration)
static unsigned int
get_previous_lcore_id(unsigned int lcore_id)
{
- int i;
+ int i;
- for (i = lcore_id - 1; i >= 0; i--)
- if (rte_lcore_is_enabled(i))
- return i;
+ for (i = lcore_id - 1; i >= 0; i--)
+ if (rte_lcore_is_enabled(i))
+ return i;
- return -1;
+ return -1;
}
/**
@@ -139,125 +140,133 @@ get_previous_lcore_id(unsigned int lcore_id)
static unsigned int
get_last_lcore_id(void)
{
- int i;
+ int i;
- for (i = RTE_MAX_LCORE; i >= 0; i--)
- if (rte_lcore_is_enabled(i))
- return i;
+ for (i = RTE_MAX_LCORE; i >= 0; i--)
+ if (rte_lcore_is_enabled(i))
+ return i;
- return 0;
+ return 0;
}
static void
receive_stage(__attribute__((unused)) void *args)
{
- int i, ret;
+ int i, ret;
- uint8_t port_id;
- uint16_t nb_rx_pkts;
+ uint8_t port_id;
+ uint16_t nb_rx_pkts;
- unsigned int lcore_id;
+ unsigned int lcore_id;
- struct rte_mbuf *pkts[MAX_PKT_QUOTA];
- struct rte_ring *ring;
- enum ring_state ring_state[RTE_MAX_ETHPORTS] = { RING_READY };
+ struct rte_mbuf *pkts[MAX_PKT_QUOTA];
+ struct rte_ring *ring;
+ enum ring_state ring_state[RTE_MAX_ETHPORTS] = { RING_READY };
- lcore_id = rte_lcore_id();
+ lcore_id = rte_lcore_id();
- RTE_LOG(INFO, USER1,
- "%s() started on core %u\n", __func__, lcore_id);
+ RTE_LOG(INFO, USER1,
+ "%s() started on core %u\n", __func__, lcore_id);
- while (1) {
+ while (1) {
- /* Process each port round robin style */
- for (port_id = 0; port_id < RTE_MAX_ETHPORTS; port_id++) {
+ /* Process each port round robin style */
+ for (port_id = 0; port_id < RTE_MAX_ETHPORTS; port_id++) {
- if (!is_bit_set(port_id, portmask))
- continue;
+ if (!is_bit_set(port_id, portmask))
+ continue;
- ring = rings[lcore_id][port_id];
+ ring = rings[lcore_id][port_id];
- if (ring_state[port_id] != RING_READY) {
- if (rte_ring_count(ring) > *low_watermark)
- continue;
- else
- ring_state[port_id] = RING_READY;
- }
+ if (ring_state[port_id] != RING_READY) {
+ if (rte_ring_count(ring) > *low_watermark)
+ continue;
+ else
+ ring_state[port_id] = RING_READY;
+ }
- /* Enqueue received packets on the RX ring */
- nb_rx_pkts = rte_eth_rx_burst(port_id, 0, pkts, (uint16_t) *quota);
- ret = rte_ring_enqueue_bulk(ring, (void *) pkts, nb_rx_pkts);
- if (ret == -EDQUOT) {
- ring_state[port_id] = RING_OVERLOADED;
- send_pause_frame(port_id, 1337);
- }
+ /* Enqueue received packets on the RX ring */
+ nb_rx_pkts = rte_eth_rx_burst(port_id, 0, pkts,
+ (uint16_t) *quota);
+ ret = rte_ring_enqueue_bulk(ring, (void *) pkts,
+ nb_rx_pkts);
+ if (ret == -EDQUOT) {
+ ring_state[port_id] = RING_OVERLOADED;
+ send_pause_frame(port_id, 1337);
+ }
- else if (ret == -ENOBUFS) {
+ else if (ret == -ENOBUFS) {
- /* Return mbufs to the pool, effectively dropping packets */
- for (i = 0; i < nb_rx_pkts; i++)
- rte_pktmbuf_free(pkts[i]);
- }
- }
- }
+ /*
+ * Return mbufs to the pool,
+ * effectively dropping packets
+ */
+ for (i = 0; i < nb_rx_pkts; i++)
+ rte_pktmbuf_free(pkts[i]);
+ }
+ }
+ }
}
static void
pipeline_stage(__attribute__((unused)) void *args)
{
- int i, ret;
- int nb_dq_pkts;
+ int i, ret;
+ int nb_dq_pkts;
- uint8_t port_id;
+ uint8_t port_id;
- unsigned int lcore_id, previous_lcore_id;
+ unsigned int lcore_id, previous_lcore_id;
- void *pkts[MAX_PKT_QUOTA];
- struct rte_ring *rx, *tx;
- enum ring_state ring_state[RTE_MAX_ETHPORTS] = { RING_READY };
+ void *pkts[MAX_PKT_QUOTA];
+ struct rte_ring *rx, *tx;
+ enum ring_state ring_state[RTE_MAX_ETHPORTS] = { RING_READY };
- lcore_id = rte_lcore_id();
- previous_lcore_id = get_previous_lcore_id(lcore_id);
+ lcore_id = rte_lcore_id();
+ previous_lcore_id = get_previous_lcore_id(lcore_id);
- RTE_LOG(INFO, USER1,
- "%s() started on core %u - processing packets from core %u\n",
- __func__, lcore_id, previous_lcore_id);
+ RTE_LOG(INFO, USER1,
+ "%s() started on core %u - processing packets from core %u\n",
+ __func__, lcore_id, previous_lcore_id);
- while (1) {
+ while (1) {
- for (port_id = 0; port_id < RTE_MAX_ETHPORTS; port_id++) {
+ for (port_id = 0; port_id < RTE_MAX_ETHPORTS; port_id++) {
- if (!is_bit_set(port_id, portmask))
- continue;
+ if (!is_bit_set(port_id, portmask))
+ continue;
- tx = rings[lcore_id][port_id];
- rx = rings[previous_lcore_id][port_id];
+ tx = rings[lcore_id][port_id];
+ rx = rings[previous_lcore_id][port_id];
- if (ring_state[port_id] != RING_READY) {
- if (rte_ring_count(tx) > *low_watermark)
- continue;
- else
- ring_state[port_id] = RING_READY;
- }
+ if (ring_state[port_id] != RING_READY) {
+ if (rte_ring_count(tx) > *low_watermark)
+ continue;
+ else
+ ring_state[port_id] = RING_READY;
+ }
- /* Dequeue up to quota mbuf from rx */
- nb_dq_pkts = rte_ring_dequeue_burst(rx, pkts, *quota);
- if (unlikely(nb_dq_pkts < 0))
- continue;
+ /* Dequeue up to quota mbuf from rx */
+ nb_dq_pkts = rte_ring_dequeue_burst(rx, pkts, *quota);
+ if (unlikely(nb_dq_pkts < 0))
+ continue;
- /* Enqueue them on tx */
- ret = rte_ring_enqueue_bulk(tx, pkts, nb_dq_pkts);
- if (ret == -EDQUOT)
- ring_state[port_id] = RING_OVERLOADED;
+ /* Enqueue them on tx */
+ ret = rte_ring_enqueue_bulk(tx, pkts, nb_dq_pkts);
+ if (ret == -EDQUOT)
+ ring_state[port_id] = RING_OVERLOADED;
- else if (ret == -ENOBUFS) {
+ else if (ret == -ENOBUFS) {
- /* Return mbufs to the pool, effectively dropping packets */
- for (i = 0; i < nb_dq_pkts; i++)
- rte_pktmbuf_free(pkts[i]);
- }
- }
- }
+ /*
+ * Return mbufs to the pool,
+ * effectively dropping packets
+ */
+ for (i = 0; i < nb_dq_pkts; i++)
+ rte_pktmbuf_free(pkts[i]);
+ }
+ }
+ }
}
static void
@@ -265,108 +274,114 @@ send_stage(__attribute__((unused)) void *args)
{
uint16_t nb_dq_pkts;
- uint8_t port_id;
- uint8_t dest_port_id;
+ uint8_t port_id;
+ uint8_t dest_port_id;
- unsigned int lcore_id, previous_lcore_id;
+ unsigned int lcore_id, previous_lcore_id;
- struct rte_ring *tx;
- struct rte_mbuf *tx_pkts[MAX_PKT_QUOTA];
+ struct rte_ring *tx;
+ struct rte_mbuf *tx_pkts[MAX_PKT_QUOTA];
- lcore_id = rte_lcore_id();
- previous_lcore_id = get_previous_lcore_id(lcore_id);
+ lcore_id = rte_lcore_id();
+ previous_lcore_id = get_previous_lcore_id(lcore_id);
- RTE_LOG(INFO, USER1,
- "%s() started on core %u - processing packets from core %u\n",
- __func__, lcore_id, previous_lcore_id);
+ RTE_LOG(INFO, USER1,
+ "%s() started on core %u - processing packets from core %u\n",
+ __func__, lcore_id, previous_lcore_id);
- while (1) {
+ while (1) {
- /* Process each ring round robin style */
- for (port_id = 0; port_id < RTE_MAX_ETHPORTS; port_id++) {
+ /* Process each ring round robin style */
+ for (port_id = 0; port_id < RTE_MAX_ETHPORTS; port_id++) {
- if (!is_bit_set(port_id, portmask))
- continue;
+ if (!is_bit_set(port_id, portmask))
+ continue;
- dest_port_id = port_pairs[port_id];
- tx = rings[previous_lcore_id][port_id];
+ dest_port_id = port_pairs[port_id];
+ tx = rings[previous_lcore_id][port_id];
- if (rte_ring_empty(tx))
- continue;
+ if (rte_ring_empty(tx))
+ continue;
- /* Dequeue packets from tx and send them */
- nb_dq_pkts = (uint16_t) rte_ring_dequeue_burst(tx, (void *) tx_pkts, *quota);
- rte_eth_tx_burst(dest_port_id, 0, tx_pkts, nb_dq_pkts);
+ /* Dequeue packets from tx and send them */
+ nb_dq_pkts = (uint16_t) rte_ring_dequeue_burst(tx,
+ (void *) tx_pkts, *quota);
+ rte_eth_tx_burst(dest_port_id, 0, tx_pkts, nb_dq_pkts);
- /* TODO: Check if nb_dq_pkts == nb_tx_pkts? */
- }
- }
+ /* TODO: Check if nb_dq_pkts == nb_tx_pkts? */
+ }
+ }
}
int
main(int argc, char **argv)
{
- int ret;
- unsigned int lcore_id, master_lcore_id, last_lcore_id;
+ int ret;
+ unsigned int lcore_id, master_lcore_id, last_lcore_id;
- uint8_t port_id;
+ uint8_t port_id;
- rte_set_log_level(RTE_LOG_INFO);
+ rte_set_log_level(RTE_LOG_INFO);
- ret = rte_eal_init(argc, argv);
- if (ret < 0)
- rte_exit(EXIT_FAILURE, "Cannot initialize EAL\n");
+ ret = rte_eal_init(argc, argv);
+ if (ret < 0)
+ rte_exit(EXIT_FAILURE, "Cannot initialize EAL\n");
- argc -= ret;
- argv += ret;
+ argc -= ret;
+ argv += ret;
- init_dpdk();
- setup_shared_variables();
+ init_dpdk();
+ setup_shared_variables();
- *quota = 32;
- *low_watermark = 60 * RING_SIZE / 100;
+ *quota = 32;
+ *low_watermark = 60 * RING_SIZE / 100;
- last_lcore_id = get_last_lcore_id();
- master_lcore_id = rte_get_master_lcore();
+ last_lcore_id = get_last_lcore_id();
+ master_lcore_id = rte_get_master_lcore();
- /* Parse the application's arguments */
- ret = parse_qw_args(argc, argv);
- if (ret < 0)
- rte_exit(EXIT_FAILURE, "Invalid quota/watermark argument(s)\n");
+ /* Parse the application's arguments */
+ ret = parse_qw_args(argc, argv);
+ if (ret < 0)
+ rte_exit(EXIT_FAILURE, "Invalid quota/watermark argument(s)\n");
- /* Create a pool of mbuf to store packets */
- mbuf_pool = rte_pktmbuf_pool_create("mbuf_pool", MBUF_PER_POOL, 32, 0,
- MBUF_DATA_SIZE, rte_socket_id());
- if (mbuf_pool == NULL)
- rte_panic("%s\n", rte_strerror(rte_errno));
+ /* Create a pool of mbuf to store packets */
+ mbuf_pool = rte_pktmbuf_pool_create("mbuf_pool", MBUF_PER_POOL, 32, 0,
+ MBUF_DATA_SIZE, rte_socket_id());
+ if (mbuf_pool == NULL)
+ rte_panic("%s\n", rte_strerror(rte_errno));
- for (port_id = 0; port_id < RTE_MAX_ETHPORTS; port_id++)
- if (is_bit_set(port_id, portmask)) {
- configure_eth_port(port_id);
- init_ring(master_lcore_id, port_id);
- }
+ for (port_id = 0; port_id < RTE_MAX_ETHPORTS; port_id++)
+ if (is_bit_set(port_id, portmask)) {
+ configure_eth_port(port_id);
+ init_ring(master_lcore_id, port_id);
+ }
- pair_ports();
+ pair_ports();
- /* Start pipeline_connect() on all the available slave lcore but the last */
- for (lcore_id = 0 ; lcore_id < last_lcore_id; lcore_id++) {
- if (rte_lcore_is_enabled(lcore_id) && lcore_id != master_lcore_id) {
+ /*
+ * Start pipeline_connect() on all the available slave lcores
+ * but the last
+ */
+ for (lcore_id = 0 ; lcore_id < last_lcore_id; lcore_id++) {
+ if (rte_lcore_is_enabled(lcore_id) &&
+ lcore_id != master_lcore_id) {
- for (port_id = 0; port_id < RTE_MAX_ETHPORTS; port_id++)
- if (is_bit_set(port_id, portmask))
- init_ring(lcore_id, port_id);
+ for (port_id = 0; port_id < RTE_MAX_ETHPORTS; port_id++)
+ if (is_bit_set(port_id, portmask))
+ init_ring(lcore_id, port_id);
- /* typecast is a workaround for GCC 4.3 bug */
- rte_eal_remote_launch((int (*)(void *))pipeline_stage, NULL, lcore_id);
- }
- }
+ /* typecast is a workaround for GCC 4.3 bug */
+ rte_eal_remote_launch((int (*)(void *))pipeline_stage,
+ NULL, lcore_id);
+ }
+ }
- /* Start send_stage() on the last slave core */
- /* typecast is a workaround for GCC 4.3 bug */
- rte_eal_remote_launch((int (*)(void *))send_stage, NULL, last_lcore_id);
+ /* Start send_stage() on the last slave core */
+ /* typecast is a workaround for GCC 4.3 bug */
+ rte_eal_remote_launch((int (*)(void *))send_stage, NULL, last_lcore_id);
- /* Start receive_stage() on the master core */
- receive_stage(NULL);
+ /* Start receive_stage() on the master core */
+ receive_stage(NULL);
- return 0;
+ return 0;
}
diff --git a/examples/quota_watermark/qw/main.h b/examples/quota_watermark/qw/main.h
index 6b36489..545ba42 100644
--- a/examples/quota_watermark/qw/main.h
+++ b/examples/quota_watermark/qw/main.h
@@ -37,8 +37,8 @@
#include "../include/conf.h"
enum ring_state {
- RING_READY,
- RING_OVERLOADED,
+ RING_READY,
+ RING_OVERLOADED,
};
extern int *quota;
@@ -53,7 +53,7 @@ extern struct rte_mempool *mbuf_pool;
static inline int
is_bit_set(int i, unsigned int mask)
{
- return (1 << i) & mask;
+ return (1 << i) & mask;
}
#endif /* _MAIN_H_ */
diff --git a/examples/quota_watermark/qwctl/commands.c b/examples/quota_watermark/qwctl/commands.c
index 5348dd3..036bf80 100644
--- a/examples/quota_watermark/qwctl/commands.c
+++ b/examples/quota_watermark/qwctl/commands.c
@@ -53,36 +53,36 @@
*/
struct cmd_help_tokens {
- cmdline_fixed_string_t verb;
+ cmdline_fixed_string_t verb;
};
cmdline_parse_token_string_t cmd_help_verb =
- TOKEN_STRING_INITIALIZER(struct cmd_help_tokens, verb, "help");
+ TOKEN_STRING_INITIALIZER(struct cmd_help_tokens, verb, "help");
static void
cmd_help_handler(__attribute__((unused)) void *parsed_result,
- struct cmdline *cl,
- __attribute__((unused)) void *data)
+ struct cmdline *cl,
+ __attribute__((unused)) void *data)
{
- cmdline_printf(cl, "Available commands:\n"
- "- help\n"
- "- set [ring_name|variable] <value>\n"
- "- show [ring_name|variable]\n"
- "\n"
- "Available variables:\n"
- "- low_watermark\n"
- "- quota\n"
- "- ring names follow the core%%u_port%%u format\n");
+ cmdline_printf(cl, "Available commands:\n"
+ "- help\n"
+ "- set [ring_name|variable] <value>\n"
+ "- show [ring_name|variable]\n"
+ "\n"
+ "Available variables:\n"
+ "- low_watermark\n"
+ "- quota\n"
+ "- ring names follow the core%%u_port%%u format\n");
}
cmdline_parse_inst_t cmd_help = {
- .f = cmd_help_handler,
- .data = NULL,
- .help_str = "show help",
- .tokens = {
- (void *) &cmd_help_verb,
- NULL,
- },
+ .f = cmd_help_handler,
+ .data = NULL,
+ .help_str = "show help",
+ .tokens = {
+ (void *) &cmd_help_verb,
+ NULL,
+ },
};
@@ -91,69 +91,74 @@ cmdline_parse_inst_t cmd_help = {
*/
struct cmd_set_tokens {
- cmdline_fixed_string_t verb;
- cmdline_fixed_string_t variable;
- uint32_t value;
+ cmdline_fixed_string_t verb;
+ cmdline_fixed_string_t variable;
+ uint32_t value;
};
cmdline_parse_token_string_t cmd_set_verb =
- TOKEN_STRING_INITIALIZER(struct cmd_set_tokens, verb, "set");
+ TOKEN_STRING_INITIALIZER(struct cmd_set_tokens, verb, "set");
cmdline_parse_token_string_t cmd_set_variable =
- TOKEN_STRING_INITIALIZER(struct cmd_set_tokens, variable, NULL);
+ TOKEN_STRING_INITIALIZER(struct cmd_set_tokens, variable, NULL);
cmdline_parse_token_num_t cmd_set_value =
- TOKEN_NUM_INITIALIZER(struct cmd_set_tokens, value, UINT32);
+ TOKEN_NUM_INITIALIZER(struct cmd_set_tokens, value, UINT32);
static void
cmd_set_handler(__attribute__((unused)) void *parsed_result,
- struct cmdline *cl,
- __attribute__((unused)) void *data)
+ struct cmdline *cl,
+ __attribute__((unused)) void *data)
{
- struct cmd_set_tokens *tokens = parsed_result;
- struct rte_ring *ring;
-
- if (!strcmp(tokens->variable, "quota")) {
-
- if (tokens->value > 0 && tokens->value <= MAX_PKT_QUOTA)
- *quota = tokens->value;
- else
- cmdline_printf(cl, "quota must be between 1 and %u\n", MAX_PKT_QUOTA);
- }
-
- else if (!strcmp(tokens->variable, "low_watermark")) {
-
- if (tokens->value <= 100)
- *low_watermark = tokens->value * RING_SIZE / 100;
- else
- cmdline_printf(cl, "low_watermark must be between 0%% and 100%%\n");
- }
-
- else {
-
- ring = rte_ring_lookup(tokens->variable);
- if (ring == NULL)
- cmdline_printf(cl, "Cannot find ring \"%s\"\n", tokens->variable);
- else
- if (tokens->value >= *low_watermark * 100 / RING_SIZE
- && tokens->value <= 100)
- rte_ring_set_water_mark(ring, tokens->value * RING_SIZE / 100);
- else
- cmdline_printf(cl, "ring high watermark must be between %u%% "
- "and 100%%\n", *low_watermark * 100 / RING_SIZE);
- }
+ struct cmd_set_tokens *tokens = parsed_result;
+ struct rte_ring *ring;
+
+ if (!strcmp(tokens->variable, "quota")) {
+
+ if (tokens->value > 0 && tokens->value <= MAX_PKT_QUOTA)
+ *quota = tokens->value;
+ else
+ cmdline_printf(cl, "quota must be between 1 and %u\n",
+ MAX_PKT_QUOTA);
+ }
+
+ else if (!strcmp(tokens->variable, "low_watermark")) {
+
+ if (tokens->value <= 100)
+ *low_watermark = tokens->value * RING_SIZE / 100;
+ else
+ cmdline_printf(cl,
+ "low_watermark must be between 0%% and 100%%\n");
+ }
+
+ else {
+
+ ring = rte_ring_lookup(tokens->variable);
+ if (ring == NULL)
+ cmdline_printf(cl, "Cannot find ring \"%s\"\n",
+ tokens->variable);
+ else
+ if (tokens->value >= *low_watermark * 100 / RING_SIZE
+ && tokens->value <= 100)
+ rte_ring_set_water_mark(ring,
+ tokens->value * RING_SIZE / 100);
+ else
+ cmdline_printf(cl,
+ "ring high watermark must be between %u%% and 100%%\n",
+ *low_watermark * 100 / RING_SIZE);
+ }
}
cmdline_parse_inst_t cmd_set = {
- .f = cmd_set_handler,
- .data = NULL,
- .help_str = "Set a variable value",
- .tokens = {
- (void *) &cmd_set_verb,
- (void *) &cmd_set_variable,
- (void *) &cmd_set_value,
- NULL,
- },
+ .f = cmd_set_handler,
+ .data = NULL,
+ .help_str = "Set a variable value",
+ .tokens = {
+ (void *) &cmd_set_verb,
+ (void *) &cmd_set_variable,
+ (void *) &cmd_set_value,
+ NULL,
+ },
};
@@ -162,56 +167,59 @@ cmdline_parse_inst_t cmd_set = {
*/
struct cmd_show_tokens {
- cmdline_fixed_string_t verb;
- cmdline_fixed_string_t variable;
+ cmdline_fixed_string_t verb;
+ cmdline_fixed_string_t variable;
};
cmdline_parse_token_string_t cmd_show_verb =
- TOKEN_STRING_INITIALIZER(struct cmd_show_tokens, verb, "show");
+ TOKEN_STRING_INITIALIZER(struct cmd_show_tokens, verb, "show");
cmdline_parse_token_string_t cmd_show_variable =
- TOKEN_STRING_INITIALIZER(struct cmd_show_tokens, variable, NULL);
+ TOKEN_STRING_INITIALIZER(struct cmd_show_tokens,
+ variable, NULL);
static void
cmd_show_handler(__attribute__((unused)) void *parsed_result,
- struct cmdline *cl,
- __attribute__((unused)) void *data)
+ struct cmdline *cl,
+ __attribute__((unused)) void *data)
{
- struct cmd_show_tokens *tokens = parsed_result;
- struct rte_ring *ring;
+ struct cmd_show_tokens *tokens = parsed_result;
+ struct rte_ring *ring;
- if (!strcmp(tokens->variable, "quota"))
- cmdline_printf(cl, "Global quota: %d\n", *quota);
+ if (!strcmp(tokens->variable, "quota"))
+ cmdline_printf(cl, "Global quota: %d\n", *quota);
- else if (!strcmp(tokens->variable, "low_watermark"))
- cmdline_printf(cl, "Global low_watermark: %u\n", *low_watermark);
+ else if (!strcmp(tokens->variable, "low_watermark"))
+ cmdline_printf(cl, "Global low_watermark: %u\n",
+ *low_watermark);
- else {
+ else {
- ring = rte_ring_lookup(tokens->variable);
- if (ring == NULL)
- cmdline_printf(cl, "Cannot find ring \"%s\"\n", tokens->variable);
- else
- rte_ring_dump(stdout, ring);
- }
+ ring = rte_ring_lookup(tokens->variable);
+ if (ring == NULL)
+ cmdline_printf(cl, "Cannot find ring \"%s\"\n",
+ tokens->variable);
+ else
+ rte_ring_dump(stdout, ring);
+ }
}
cmdline_parse_inst_t cmd_show = {
- .f = cmd_show_handler,
- .data = NULL,
- .help_str = "Show a variable value",
- .tokens = {
- (void *) &cmd_show_verb,
- (void *) &cmd_show_variable,
- NULL,
- },
+ .f = cmd_show_handler,
+ .data = NULL,
+ .help_str = "Show a variable value",
+ .tokens = {
+ (void *) &cmd_show_verb,
+ (void *) &cmd_show_variable,
+ NULL,
+ },
};
cmdline_parse_ctx_t qwctl_ctx[] = {
- (cmdline_parse_inst_t *)&cmd_help,
- (cmdline_parse_inst_t *)&cmd_set,
- (cmdline_parse_inst_t *)&cmd_show,
- NULL,
+ (cmdline_parse_inst_t *)&cmd_help,
+ (cmdline_parse_inst_t *)&cmd_set,
+ (cmdline_parse_inst_t *)&cmd_show,
+ NULL,
};
diff --git a/examples/quota_watermark/qwctl/qwctl.c b/examples/quota_watermark/qwctl/qwctl.c
index 29c501c..3a85cc3 100644
--- a/examples/quota_watermark/qwctl/qwctl.c
+++ b/examples/quota_watermark/qwctl/qwctl.c
@@ -60,35 +60,35 @@ unsigned int *low_watermark;
static void
setup_shared_variables(void)
{
- const struct rte_memzone *qw_memzone;
+ const struct rte_memzone *qw_memzone;
- qw_memzone = rte_memzone_lookup(QUOTA_WATERMARK_MEMZONE_NAME);
- if (qw_memzone == NULL)
- rte_exit(EXIT_FAILURE, "Couldn't find memzone\n");
+ qw_memzone = rte_memzone_lookup(QUOTA_WATERMARK_MEMZONE_NAME);
+ if (qw_memzone == NULL)
+ rte_exit(EXIT_FAILURE, "Couldn't find memzone\n");
- quota = qw_memzone->addr;
- low_watermark = (unsigned int *) qw_memzone->addr + 1;
+ quota = qw_memzone->addr;
+ low_watermark = (unsigned int *) qw_memzone->addr + 1;
}
int main(int argc, char **argv)
{
- int ret;
- struct cmdline *cl;
+ int ret;
+ struct cmdline *cl;
- rte_set_log_level(RTE_LOG_INFO);
+ rte_set_log_level(RTE_LOG_INFO);
- ret = rte_eal_init(argc, argv);
- if (ret < 0)
- rte_exit(EXIT_FAILURE, "Cannot initialize EAL\n");
+ ret = rte_eal_init(argc, argv);
+ if (ret < 0)
+ rte_exit(EXIT_FAILURE, "Cannot initialize EAL\n");
- setup_shared_variables();
+ setup_shared_variables();
- cl = cmdline_stdin_new(qwctl_ctx, "qwctl> ");
- if (cl == NULL)
- rte_exit(EXIT_FAILURE, "Cannot create cmdline instance\n");
+ cl = cmdline_stdin_new(qwctl_ctx, "qwctl> ");
+ if (cl == NULL)
+ rte_exit(EXIT_FAILURE, "Cannot create cmdline instance\n");
- cmdline_interact(cl);
- cmdline_stdin_exit(cl);
+ cmdline_interact(cl);
+ cmdline_stdin_exit(cl);
- return 0;
+ return 0;
}
--
2.9.3
^ permalink raw reply [flat|nested] 15+ messages in thread
* [dpdk-dev] [PATCH v2 0/5] minor fixes and cleanup
2017-02-21 16:52 [dpdk-dev] [PATCH 0/4] minor fixes and cleanup Bruce Richardson
` (3 preceding siblings ...)
2017-02-21 16:52 ` [dpdk-dev] [PATCH 4/4] examples/quota_watermark: correct code indentation Bruce Richardson
@ 2017-02-23 16:41 ` Bruce Richardson
2017-02-23 17:02 ` Bruce Richardson
2017-03-08 15:09 ` Thomas Monjalon
2017-02-23 16:41 ` [dpdk-dev] [PATCH v2 1/5] app/pdump: fix duplicate macro definition Bruce Richardson
` (4 subsequent siblings)
9 siblings, 2 replies; 15+ messages in thread
From: Bruce Richardson @ 2017-02-23 16:41 UTC (permalink / raw)
To: dev; +Cc: Bruce Richardson
This patchset contains some minor fixes and improvements which
I found in the context of preparing a new patchset for the
rte_ring code. Having these merged separately reduces the
number of patches in the ring set so should make everyone's
life easier.
V2 Changes: new patch added with extra fix for quota_watermark example
Bruce Richardson (5):
app/pdump: fix duplicate macro definition
ring: add a function to return the ring size
crypto/null: use ring size function
examples/quota_watermark: correct code indentation
examples/quota_watermark: fix requirement for 2M pages
app/pdump/main.c | 1 -
drivers/crypto/null/null_crypto_pmd_ops.c | 2 +-
examples/quota_watermark/qw/args.c | 63 ++---
examples/quota_watermark/qw/init.c | 177 +++++++-------
examples/quota_watermark/qw/main.c | 377 ++++++++++++++++--------------
examples/quota_watermark/qw/main.h | 6 +-
examples/quota_watermark/qwctl/commands.c | 208 +++++++++--------
examples/quota_watermark/qwctl/qwctl.c | 38 +--
lib/librte_ring/rte_ring.h | 14 ++
9 files changed, 464 insertions(+), 422 deletions(-)
--
2.9.3
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [dpdk-dev] [PATCH v2 0/5] minor fixes and cleanup
2017-02-23 16:41 ` [dpdk-dev] [PATCH v2 0/5] minor fixes and cleanup Bruce Richardson
@ 2017-02-23 17:02 ` Bruce Richardson
2017-03-08 15:09 ` Thomas Monjalon
1 sibling, 0 replies; 15+ messages in thread
From: Bruce Richardson @ 2017-02-23 17:02 UTC (permalink / raw)
To: dev
On Thu, Feb 23, 2017 at 04:41:58PM +0000, Bruce Richardson wrote:
> This patchset contains some minor fixes and improvements which
> I found in the context of preparing a new patchset for the
> rte_ring code. Having these merged separately reduces the
> number of patches in the ring set so should make everyone's
> life easier.
>
> V2 Changes: new patch added with extra fix for quota_watermark example
>
> Bruce Richardson (5):
> app/pdump: fix duplicate macro definition
> ring: add a function to return the ring size
> crypto/null: use ring size function
> examples/quota_watermark: correct code indentation
> examples/quota_watermark: fix requirement for 2M pages
>
Apologies for the threading errors in this email chain. I was
unexpectedly using an old version of git for the send-email command. :-(
/Bruce
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [dpdk-dev] [PATCH v2 0/5] minor fixes and cleanup
2017-02-23 16:41 ` [dpdk-dev] [PATCH v2 0/5] minor fixes and cleanup Bruce Richardson
2017-02-23 17:02 ` Bruce Richardson
@ 2017-03-08 15:09 ` Thomas Monjalon
1 sibling, 0 replies; 15+ messages in thread
From: Thomas Monjalon @ 2017-03-08 15:09 UTC (permalink / raw)
To: Bruce Richardson; +Cc: dev
2017-02-23 16:41, Bruce Richardson:
> This patchset contains some minor fixes and improvements which
> I found in the context of preparing a new patchset for the
> rte_ring code. Having these merged separately reduces the
> number of patches in the ring set so should make everyone's
> life easier.
>
> V2 Changes: new patch added with extra fix for quota_watermark example
>
> Bruce Richardson (5):
> app/pdump: fix duplicate macro definition
> ring: add a function to return the ring size
> crypto/null: use ring size function
> examples/quota_watermark: correct code indentation
> examples/quota_watermark: fix requirement for 2M pages
Applied, thanks
^ permalink raw reply [flat|nested] 15+ messages in thread
* [dpdk-dev] [PATCH v2 1/5] app/pdump: fix duplicate macro definition
2017-02-21 16:52 [dpdk-dev] [PATCH 0/4] minor fixes and cleanup Bruce Richardson
` (4 preceding siblings ...)
2017-02-23 16:41 ` [dpdk-dev] [PATCH v2 0/5] minor fixes and cleanup Bruce Richardson
@ 2017-02-23 16:41 ` Bruce Richardson
2017-02-23 16:42 ` [dpdk-dev] [PATCH v2 2/5] ring: add a function to return the ring size Bruce Richardson
` (3 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Bruce Richardson @ 2017-02-23 16:41 UTC (permalink / raw)
To: dev; +Cc: Bruce Richardson
RTE_RING_SZ_MASK is redefined here with the original definition in
rte_ring.h. Since rte_ring.h is already included, just remove the
duplicate definition here.
Fixes: caa7028276b8 ("app/pdump: add tool for packet capturing")
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
app/pdump/main.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/app/pdump/main.c b/app/pdump/main.c
index f3ef181..b88090d 100644
--- a/app/pdump/main.c
+++ b/app/pdump/main.c
@@ -92,7 +92,6 @@
#define BURST_SIZE 32
#define NUM_VDEVS 2
-#define RTE_RING_SZ_MASK (unsigned)(0x0fffffff) /**< Ring size mask */
/* true if x is a power of 2 */
#define POWEROF2(x) ((((x)-1) & (x)) == 0)
--
2.9.3
^ permalink raw reply [flat|nested] 15+ messages in thread
* [dpdk-dev] [PATCH v2 2/5] ring: add a function to return the ring size
2017-02-21 16:52 [dpdk-dev] [PATCH 0/4] minor fixes and cleanup Bruce Richardson
` (5 preceding siblings ...)
2017-02-23 16:41 ` [dpdk-dev] [PATCH v2 1/5] app/pdump: fix duplicate macro definition Bruce Richardson
@ 2017-02-23 16:42 ` Bruce Richardson
2017-03-08 10:00 ` Olivier MATZ
2017-02-23 16:42 ` [dpdk-dev] [PATCH v2 3/5] crypto/null: use ring size function Bruce Richardson
` (2 subsequent siblings)
9 siblings, 1 reply; 15+ messages in thread
From: Bruce Richardson @ 2017-02-23 16:42 UTC (permalink / raw)
To: dev; +Cc: Bruce Richardson
Applications and other libraries should not be reading inside the
rte_ring structure directly to get the ring size. Instead add a fn
to allow it to be queried.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
lib/librte_ring/rte_ring.h | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/lib/librte_ring/rte_ring.h b/lib/librte_ring/rte_ring.h
index e359aff..72ccca5 100644
--- a/lib/librte_ring/rte_ring.h
+++ b/lib/librte_ring/rte_ring.h
@@ -1108,6 +1108,20 @@ rte_ring_free_count(const struct rte_ring *r)
}
/**
+ * Return the size of the ring.
+ *
+ * @param r
+ * A pointer to the ring structure.
+ * @return
+ * The number of elements which can be stored in the ring.
+ */
+static inline unsigned int
+rte_ring_get_size(const struct rte_ring *r)
+{
+ return r->prod.size;
+}
+
+/**
* Dump the status of all rings on the console
*
* @param f
--
2.9.3
^ permalink raw reply [flat|nested] 15+ messages in thread
* [dpdk-dev] [PATCH v2 3/5] crypto/null: use ring size function
2017-02-21 16:52 [dpdk-dev] [PATCH 0/4] minor fixes and cleanup Bruce Richardson
` (6 preceding siblings ...)
2017-02-23 16:42 ` [dpdk-dev] [PATCH v2 2/5] ring: add a function to return the ring size Bruce Richardson
@ 2017-02-23 16:42 ` Bruce Richardson
2017-02-24 14:20 ` Doherty, Declan
2017-02-23 16:42 ` [dpdk-dev] [PATCH v2 4/5] examples/quota_watermark: correct code indentation Bruce Richardson
2017-02-23 16:42 ` [dpdk-dev] [PATCH v2 5/5] examples/quota_watermark: fix requirement for 2M pages Bruce Richardson
9 siblings, 1 reply; 15+ messages in thread
From: Bruce Richardson @ 2017-02-23 16:42 UTC (permalink / raw)
To: dev; +Cc: Bruce Richardson
Rather than reading the size directly from the ring structure,
use the dedicated function for that purpose.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
drivers/crypto/null/null_crypto_pmd_ops.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/crypto/null/null_crypto_pmd_ops.c b/drivers/crypto/null/null_crypto_pmd_ops.c
index 26ff631..4a24537 100644
--- a/drivers/crypto/null/null_crypto_pmd_ops.c
+++ b/drivers/crypto/null/null_crypto_pmd_ops.c
@@ -193,7 +193,7 @@ null_crypto_pmd_qp_create_processed_pkts_ring(struct null_crypto_qp *qp,
r = rte_ring_lookup(qp->name);
if (r) {
- if (r->prod.size >= ring_size) {
+ if (rte_ring_get_size(r) >= ring_size) {
NULL_CRYPTO_LOG_INFO(
"Reusing existing ring %s for processed packets",
qp->name);
--
2.9.3
^ permalink raw reply [flat|nested] 15+ messages in thread
* [dpdk-dev] [PATCH v2 4/5] examples/quota_watermark: correct code indentation
2017-02-21 16:52 [dpdk-dev] [PATCH 0/4] minor fixes and cleanup Bruce Richardson
` (7 preceding siblings ...)
2017-02-23 16:42 ` [dpdk-dev] [PATCH v2 3/5] crypto/null: use ring size function Bruce Richardson
@ 2017-02-23 16:42 ` Bruce Richardson
2017-02-23 16:42 ` [dpdk-dev] [PATCH v2 5/5] examples/quota_watermark: fix requirement for 2M pages Bruce Richardson
9 siblings, 0 replies; 15+ messages in thread
From: Bruce Richardson @ 2017-02-23 16:42 UTC (permalink / raw)
To: dev; +Cc: Bruce Richardson
The code indentation in the example app files used spaces rather than
tabs for indentation, and as such did not conform to DPDK conventions.
This left those modifying the code in a bind - to fix things on a line
by line basis so as to avoid checkpatch errors, or to keep things
consistent within the file, and accept checkpatch errors.
Since these files have not had too many changes since the original
import, there is little change history to lose by doing a complete
reformatting of the code, so just update all indentation to standard.
In the process, wrap long lines appropriately, avoiding splitting
error messages.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
examples/quota_watermark/qw/args.c | 63 ++---
examples/quota_watermark/qw/init.c | 177 +++++++-------
examples/quota_watermark/qw/main.c | 377 ++++++++++++++++--------------
examples/quota_watermark/qw/main.h | 6 +-
examples/quota_watermark/qwctl/commands.c | 208 +++++++++--------
examples/quota_watermark/qwctl/qwctl.c | 38 +--
6 files changed, 449 insertions(+), 420 deletions(-)
diff --git a/examples/quota_watermark/qw/args.c b/examples/quota_watermark/qw/args.c
index 408b54d..6ba77bc 100644
--- a/examples/quota_watermark/qw/args.c
+++ b/examples/quota_watermark/qw/args.c
@@ -47,9 +47,9 @@ unsigned int portmask = 0;
static void
usage(const char *prgname)
{
- fprintf(stderr, "Usage: %s [EAL args] -- -p <portmask>\n"
- "-p PORTMASK: hexadecimal bitmask of NIC ports to configure\n",
- prgname);
+ fprintf(stderr, "Usage: %s [EAL args] -- -p <portmask>\n"
+ "-p PORTMASK: hexadecimal bitmask of NIC ports to configure\n",
+ prgname);
}
static unsigned long
@@ -61,44 +61,47 @@ parse_portmask(const char *portmask_str)
static void
check_core_count(void)
{
- if (rte_lcore_count() < 3)
- rte_exit(EXIT_FAILURE, "At least 3 cores need to be passed in the coremask\n");
+ if (rte_lcore_count() < 3)
+ rte_exit(EXIT_FAILURE,
+ "At least 3 cores need to be passed in the coremask\n");
}
static void
check_portmask_value(unsigned int portmask)
{
- unsigned int port_nb = 0;
+ unsigned int port_nb = 0;
- port_nb = __builtin_popcount(portmask);
+ port_nb = __builtin_popcount(portmask);
- if (port_nb == 0)
- rte_exit(EXIT_FAILURE, "At least 2 ports need to be passed in the portmask\n");
+ if (port_nb == 0)
+ rte_exit(EXIT_FAILURE,
+ "At least 2 ports need to be passed in the portmask\n");
- if (port_nb % 2 != 0)
- rte_exit(EXIT_FAILURE, "An even number of ports is required in the portmask\n");
+ if (port_nb % 2 != 0)
+ rte_exit(EXIT_FAILURE,
+ "An even number of ports is required in the portmask\n");
}
int
parse_qw_args(int argc, char **argv)
{
- int opt;
-
- while ((opt = getopt(argc, argv, "h:p:")) != -1) {
- switch (opt) {
- case 'h':
- usage(argv[0]);
- break;
- case 'p':
- portmask = parse_portmask(optarg);
- break;
- default:
- usage(argv[0]);
- }
- }
-
- check_core_count();
- check_portmask_value(portmask);
-
- return 0;
+ int opt;
+
+ while ((opt = getopt(argc, argv, "h:p:")) != -1) {
+ switch (opt) {
+ case 'h':
+ usage(argv[0]);
+ break;
+ case 'p':
+ portmask = parse_portmask(optarg);
+ break;
+ default:
+ usage(argv[0]);
+ }
+ }
+
+ check_core_count();
+ check_portmask_value(portmask);
+
+ return 0;
}
diff --git a/examples/quota_watermark/qw/init.c b/examples/quota_watermark/qw/init.c
index c208721..e941ce8 100644
--- a/examples/quota_watermark/qw/init.c
+++ b/examples/quota_watermark/qw/init.c
@@ -51,124 +51,127 @@
static const struct rte_eth_conf port_conf = {
- .rxmode = {
- .split_hdr_size = 0,
- .header_split = 0, /**< Header Split disabled */
- .hw_ip_checksum = 0, /**< IP checksum offload disabled */
- .hw_vlan_filter = 0, /**< VLAN filtering disabled */
- .jumbo_frame = 0, /**< Jumbo Frame Support disabled */
- .hw_strip_crc = 0, /**< CRC stripped by hardware */
- },
- .txmode = {
- .mq_mode = ETH_DCB_NONE,
- },
+ .rxmode = {
+ .split_hdr_size = 0,
+ .header_split = 0, /**< Header Split disabled */
+ .hw_ip_checksum = 0, /**< IP csum offload disabled */
+ .hw_vlan_filter = 0, /**< VLAN filtering disabled */
+ .jumbo_frame = 0, /**< Jumbo Frame disabled */
+ .hw_strip_crc = 0, /**< CRC stripped by hardware */
+ },
+ .txmode = {
+ .mq_mode = ETH_DCB_NONE,
+ },
};
static struct rte_eth_fc_conf fc_conf = {
- .mode = RTE_FC_TX_PAUSE,
- .high_water = 80 * 510 / 100,
- .low_water = 60 * 510 / 100,
- .pause_time = 1337,
- .send_xon = 0,
+ .mode = RTE_FC_TX_PAUSE,
+ .high_water = 80 * 510 / 100,
+ .low_water = 60 * 510 / 100,
+ .pause_time = 1337,
+ .send_xon = 0,
};
void configure_eth_port(uint8_t port_id)
{
- int ret;
-
- rte_eth_dev_stop(port_id);
-
- ret = rte_eth_dev_configure(port_id, 1, 1, &port_conf);
- if (ret < 0)
- rte_exit(EXIT_FAILURE, "Cannot configure port %u (error %d)\n",
- (unsigned) port_id, ret);
-
- /* Initialize the port's RX queue */
- ret = rte_eth_rx_queue_setup(port_id, 0, RX_DESC_PER_QUEUE,
- rte_eth_dev_socket_id(port_id),
- NULL,
- mbuf_pool);
- if (ret < 0)
- rte_exit(EXIT_FAILURE, "Failed to setup RX queue on "
- "port %u (error %d)\n", (unsigned) port_id, ret);
-
- /* Initialize the port's TX queue */
- ret = rte_eth_tx_queue_setup(port_id, 0, TX_DESC_PER_QUEUE,
- rte_eth_dev_socket_id(port_id),
- NULL);
- if (ret < 0)
- rte_exit(EXIT_FAILURE, "Failed to setup TX queue on "
- "port %u (error %d)\n", (unsigned) port_id, ret);
-
- /* Initialize the port's flow control */
- ret = rte_eth_dev_flow_ctrl_set(port_id, &fc_conf);
- if (ret < 0)
- rte_exit(EXIT_FAILURE, "Failed to setup hardware flow control on "
- "port %u (error %d)\n", (unsigned) port_id, ret);
-
- /* Start the port */
- ret = rte_eth_dev_start(port_id);
- if (ret < 0)
- rte_exit(EXIT_FAILURE, "Failed to start port %u (error %d)\n",
- (unsigned) port_id, ret);
-
- /* Put it in promiscuous mode */
- rte_eth_promiscuous_enable(port_id);
+ int ret;
+
+ rte_eth_dev_stop(port_id);
+
+ ret = rte_eth_dev_configure(port_id, 1, 1, &port_conf);
+ if (ret < 0)
+ rte_exit(EXIT_FAILURE, "Cannot configure port %u (error %d)\n",
+ (unsigned int) port_id, ret);
+
+ /* Initialize the port's RX queue */
+ ret = rte_eth_rx_queue_setup(port_id, 0, RX_DESC_PER_QUEUE,
+ rte_eth_dev_socket_id(port_id),
+ NULL,
+ mbuf_pool);
+ if (ret < 0)
+ rte_exit(EXIT_FAILURE,
+ "Failed to setup RX queue on port %u (error %d)\n",
+ (unsigned int) port_id, ret);
+
+ /* Initialize the port's TX queue */
+ ret = rte_eth_tx_queue_setup(port_id, 0, TX_DESC_PER_QUEUE,
+ rte_eth_dev_socket_id(port_id),
+ NULL);
+ if (ret < 0)
+ rte_exit(EXIT_FAILURE,
+ "Failed to setup TX queue on port %u (error %d)\n",
+ (unsigned int) port_id, ret);
+
+ /* Initialize the port's flow control */
+ ret = rte_eth_dev_flow_ctrl_set(port_id, &fc_conf);
+ if (ret < 0)
+ rte_exit(EXIT_FAILURE,
+ "Failed to setup hardware flow control on port %u (error %d)\n",
+ (unsigned int) port_id, ret);
+
+ /* Start the port */
+ ret = rte_eth_dev_start(port_id);
+ if (ret < 0)
+ rte_exit(EXIT_FAILURE, "Failed to start port %u (error %d)\n",
+ (unsigned int) port_id, ret);
+
+ /* Put it in promiscuous mode */
+ rte_eth_promiscuous_enable(port_id);
}
void
init_dpdk(void)
{
- if (rte_eth_dev_count() < 2)
- rte_exit(EXIT_FAILURE, "Not enough ethernet port available\n");
+ if (rte_eth_dev_count() < 2)
+ rte_exit(EXIT_FAILURE, "Not enough ethernet port available\n");
}
void init_ring(int lcore_id, uint8_t port_id)
{
- struct rte_ring *ring;
- char ring_name[RTE_RING_NAMESIZE];
+ struct rte_ring *ring;
+ char ring_name[RTE_RING_NAMESIZE];
- snprintf(ring_name, RTE_RING_NAMESIZE,
- "core%d_port%d", lcore_id, port_id);
- ring = rte_ring_create(ring_name, RING_SIZE, rte_socket_id(),
- RING_F_SP_ENQ | RING_F_SC_DEQ);
+ snprintf(ring_name, RTE_RING_NAMESIZE,
+ "core%d_port%d", lcore_id, port_id);
+ ring = rte_ring_create(ring_name, RING_SIZE, rte_socket_id(),
+ RING_F_SP_ENQ | RING_F_SC_DEQ);
- if (ring == NULL)
- rte_exit(EXIT_FAILURE, "%s\n", rte_strerror(rte_errno));
+ if (ring == NULL)
+ rte_exit(EXIT_FAILURE, "%s\n", rte_strerror(rte_errno));
- rte_ring_set_water_mark(ring, 80 * RING_SIZE / 100);
+ rte_ring_set_water_mark(ring, 80 * RING_SIZE / 100);
- rings[lcore_id][port_id] = ring;
+ rings[lcore_id][port_id] = ring;
}
void
pair_ports(void)
{
- uint8_t i, j;
-
- /* Pair ports with their "closest neighbour" in the portmask */
- for (i = 0; i < RTE_MAX_ETHPORTS; i++)
- if (is_bit_set(i, portmask))
- for (j = (uint8_t) (i + 1); j < RTE_MAX_ETHPORTS; j++)
- if (is_bit_set(j, portmask)) {
- port_pairs[i] = j;
- port_pairs[j] = i;
- i = j;
- break;
- }
+ uint8_t i, j;
+
+ /* Pair ports with their "closest neighbour" in the portmask */
+ for (i = 0; i < RTE_MAX_ETHPORTS; i++)
+ if (is_bit_set(i, portmask))
+ for (j = (uint8_t) (i + 1); j < RTE_MAX_ETHPORTS; j++)
+ if (is_bit_set(j, portmask)) {
+ port_pairs[i] = j;
+ port_pairs[j] = i;
+ i = j;
+ break;
+ }
}
void
setup_shared_variables(void)
{
- const struct rte_memzone *qw_memzone;
+ const struct rte_memzone *qw_memzone;
- qw_memzone = rte_memzone_reserve(QUOTA_WATERMARK_MEMZONE_NAME, 2 * sizeof(int),
- rte_socket_id(), RTE_MEMZONE_2MB);
- if (qw_memzone == NULL)
- rte_exit(EXIT_FAILURE, "%s\n", rte_strerror(rte_errno));
+ qw_memzone = rte_memzone_reserve(QUOTA_WATERMARK_MEMZONE_NAME,
+ 2 * sizeof(int), rte_socket_id(), RTE_MEMZONE_2MB);
+ if (qw_memzone == NULL)
+ rte_exit(EXIT_FAILURE, "%s\n", rte_strerror(rte_errno));
- quota = qw_memzone->addr;
- low_watermark = (unsigned int *) qw_memzone->addr + 1;
+ quota = qw_memzone->addr;
+ low_watermark = (unsigned int *) qw_memzone->addr + 1;
}
diff --git a/examples/quota_watermark/qw/main.c b/examples/quota_watermark/qw/main.c
index 9162e28..57df8ef 100644
--- a/examples/quota_watermark/qw/main.c
+++ b/examples/quota_watermark/qw/main.c
@@ -60,8 +60,8 @@
#define ETHER_TYPE_FLOW_CONTROL 0x8808
struct ether_fc_frame {
- uint16_t opcode;
- uint16_t param;
+ uint16_t opcode;
+ uint16_t param;
} __attribute__((__packed__));
@@ -76,38 +76,39 @@ struct rte_mempool *mbuf_pool;
static void send_pause_frame(uint8_t port_id, uint16_t duration)
{
- struct rte_mbuf *mbuf;
- struct ether_fc_frame *pause_frame;
- struct ether_hdr *hdr;
- struct ether_addr mac_addr;
+ struct rte_mbuf *mbuf;
+ struct ether_fc_frame *pause_frame;
+ struct ether_hdr *hdr;
+ struct ether_addr mac_addr;
- RTE_LOG_DP(DEBUG, USER1, "Sending PAUSE frame (duration=%d) on port %d\n",
- duration, port_id);
+ RTE_LOG_DP(DEBUG, USER1,
+ "Sending PAUSE frame (duration=%d) on port %d\n",
+ duration, port_id);
- /* Get a mbuf from the pool */
- mbuf = rte_pktmbuf_alloc(mbuf_pool);
- if (unlikely(mbuf == NULL))
- return;
+ /* Get a mbuf from the pool */
+ mbuf = rte_pktmbuf_alloc(mbuf_pool);
+ if (unlikely(mbuf == NULL))
+ return;
- /* Prepare a PAUSE frame */
- hdr = rte_pktmbuf_mtod(mbuf, struct ether_hdr *);
- pause_frame = (struct ether_fc_frame *) &hdr[1];
+ /* Prepare a PAUSE frame */
+ hdr = rte_pktmbuf_mtod(mbuf, struct ether_hdr *);
+ pause_frame = (struct ether_fc_frame *) &hdr[1];
- rte_eth_macaddr_get(port_id, &mac_addr);
- ether_addr_copy(&mac_addr, &hdr->s_addr);
+ rte_eth_macaddr_get(port_id, &mac_addr);
+ ether_addr_copy(&mac_addr, &hdr->s_addr);
- void *tmp = &hdr->d_addr.addr_bytes[0];
- *((uint64_t *)tmp) = 0x010000C28001ULL;
+ void *tmp = &hdr->d_addr.addr_bytes[0];
+ *((uint64_t *)tmp) = 0x010000C28001ULL;
- hdr->ether_type = rte_cpu_to_be_16(ETHER_TYPE_FLOW_CONTROL);
+ hdr->ether_type = rte_cpu_to_be_16(ETHER_TYPE_FLOW_CONTROL);
- pause_frame->opcode = rte_cpu_to_be_16(0x0001);
- pause_frame->param = rte_cpu_to_be_16(duration);
+ pause_frame->opcode = rte_cpu_to_be_16(0x0001);
+ pause_frame->param = rte_cpu_to_be_16(duration);
- mbuf->pkt_len = 60;
- mbuf->data_len = 60;
+ mbuf->pkt_len = 60;
+ mbuf->data_len = 60;
- rte_eth_tx_burst(port_id, 0, &mbuf, 1);
+ rte_eth_tx_burst(port_id, 0, &mbuf, 1);
}
/**
@@ -121,13 +122,13 @@ static void send_pause_frame(uint8_t port_id, uint16_t duration)
static unsigned int
get_previous_lcore_id(unsigned int lcore_id)
{
- int i;
+ int i;
- for (i = lcore_id - 1; i >= 0; i--)
- if (rte_lcore_is_enabled(i))
- return i;
+ for (i = lcore_id - 1; i >= 0; i--)
+ if (rte_lcore_is_enabled(i))
+ return i;
- return -1;
+ return -1;
}
/**
@@ -139,125 +140,133 @@ get_previous_lcore_id(unsigned int lcore_id)
static unsigned int
get_last_lcore_id(void)
{
- int i;
+ int i;
- for (i = RTE_MAX_LCORE; i >= 0; i--)
- if (rte_lcore_is_enabled(i))
- return i;
+ for (i = RTE_MAX_LCORE; i >= 0; i--)
+ if (rte_lcore_is_enabled(i))
+ return i;
- return 0;
+ return 0;
}
static void
receive_stage(__attribute__((unused)) void *args)
{
- int i, ret;
+ int i, ret;
- uint8_t port_id;
- uint16_t nb_rx_pkts;
+ uint8_t port_id;
+ uint16_t nb_rx_pkts;
- unsigned int lcore_id;
+ unsigned int lcore_id;
- struct rte_mbuf *pkts[MAX_PKT_QUOTA];
- struct rte_ring *ring;
- enum ring_state ring_state[RTE_MAX_ETHPORTS] = { RING_READY };
+ struct rte_mbuf *pkts[MAX_PKT_QUOTA];
+ struct rte_ring *ring;
+ enum ring_state ring_state[RTE_MAX_ETHPORTS] = { RING_READY };
- lcore_id = rte_lcore_id();
+ lcore_id = rte_lcore_id();
- RTE_LOG(INFO, USER1,
- "%s() started on core %u\n", __func__, lcore_id);
+ RTE_LOG(INFO, USER1,
+ "%s() started on core %u\n", __func__, lcore_id);
- while (1) {
+ while (1) {
- /* Process each port round robin style */
- for (port_id = 0; port_id < RTE_MAX_ETHPORTS; port_id++) {
+ /* Process each port round robin style */
+ for (port_id = 0; port_id < RTE_MAX_ETHPORTS; port_id++) {
- if (!is_bit_set(port_id, portmask))
- continue;
+ if (!is_bit_set(port_id, portmask))
+ continue;
- ring = rings[lcore_id][port_id];
+ ring = rings[lcore_id][port_id];
- if (ring_state[port_id] != RING_READY) {
- if (rte_ring_count(ring) > *low_watermark)
- continue;
- else
- ring_state[port_id] = RING_READY;
- }
+ if (ring_state[port_id] != RING_READY) {
+ if (rte_ring_count(ring) > *low_watermark)
+ continue;
+ else
+ ring_state[port_id] = RING_READY;
+ }
- /* Enqueue received packets on the RX ring */
- nb_rx_pkts = rte_eth_rx_burst(port_id, 0, pkts, (uint16_t) *quota);
- ret = rte_ring_enqueue_bulk(ring, (void *) pkts, nb_rx_pkts);
- if (ret == -EDQUOT) {
- ring_state[port_id] = RING_OVERLOADED;
- send_pause_frame(port_id, 1337);
- }
+ /* Enqueue received packets on the RX ring */
+ nb_rx_pkts = rte_eth_rx_burst(port_id, 0, pkts,
+ (uint16_t) *quota);
+ ret = rte_ring_enqueue_bulk(ring, (void *) pkts,
+ nb_rx_pkts);
+ if (ret == -EDQUOT) {
+ ring_state[port_id] = RING_OVERLOADED;
+ send_pause_frame(port_id, 1337);
+ }
- else if (ret == -ENOBUFS) {
+ else if (ret == -ENOBUFS) {
- /* Return mbufs to the pool, effectively dropping packets */
- for (i = 0; i < nb_rx_pkts; i++)
- rte_pktmbuf_free(pkts[i]);
- }
- }
- }
+ /*
+ * Return mbufs to the pool,
+ * effectively dropping packets
+ */
+ for (i = 0; i < nb_rx_pkts; i++)
+ rte_pktmbuf_free(pkts[i]);
+ }
+ }
+ }
}
static void
pipeline_stage(__attribute__((unused)) void *args)
{
- int i, ret;
- int nb_dq_pkts;
+ int i, ret;
+ int nb_dq_pkts;
- uint8_t port_id;
+ uint8_t port_id;
- unsigned int lcore_id, previous_lcore_id;
+ unsigned int lcore_id, previous_lcore_id;
- void *pkts[MAX_PKT_QUOTA];
- struct rte_ring *rx, *tx;
- enum ring_state ring_state[RTE_MAX_ETHPORTS] = { RING_READY };
+ void *pkts[MAX_PKT_QUOTA];
+ struct rte_ring *rx, *tx;
+ enum ring_state ring_state[RTE_MAX_ETHPORTS] = { RING_READY };
- lcore_id = rte_lcore_id();
- previous_lcore_id = get_previous_lcore_id(lcore_id);
+ lcore_id = rte_lcore_id();
+ previous_lcore_id = get_previous_lcore_id(lcore_id);
- RTE_LOG(INFO, USER1,
- "%s() started on core %u - processing packets from core %u\n",
- __func__, lcore_id, previous_lcore_id);
+ RTE_LOG(INFO, USER1,
+ "%s() started on core %u - processing packets from core %u\n",
+ __func__, lcore_id, previous_lcore_id);
- while (1) {
+ while (1) {
- for (port_id = 0; port_id < RTE_MAX_ETHPORTS; port_id++) {
+ for (port_id = 0; port_id < RTE_MAX_ETHPORTS; port_id++) {
- if (!is_bit_set(port_id, portmask))
- continue;
+ if (!is_bit_set(port_id, portmask))
+ continue;
- tx = rings[lcore_id][port_id];
- rx = rings[previous_lcore_id][port_id];
+ tx = rings[lcore_id][port_id];
+ rx = rings[previous_lcore_id][port_id];
- if (ring_state[port_id] != RING_READY) {
- if (rte_ring_count(tx) > *low_watermark)
- continue;
- else
- ring_state[port_id] = RING_READY;
- }
+ if (ring_state[port_id] != RING_READY) {
+ if (rte_ring_count(tx) > *low_watermark)
+ continue;
+ else
+ ring_state[port_id] = RING_READY;
+ }
- /* Dequeue up to quota mbuf from rx */
- nb_dq_pkts = rte_ring_dequeue_burst(rx, pkts, *quota);
- if (unlikely(nb_dq_pkts < 0))
- continue;
+ /* Dequeue up to quota mbuf from rx */
+ nb_dq_pkts = rte_ring_dequeue_burst(rx, pkts, *quota);
+ if (unlikely(nb_dq_pkts < 0))
+ continue;
- /* Enqueue them on tx */
- ret = rte_ring_enqueue_bulk(tx, pkts, nb_dq_pkts);
- if (ret == -EDQUOT)
- ring_state[port_id] = RING_OVERLOADED;
+ /* Enqueue them on tx */
+ ret = rte_ring_enqueue_bulk(tx, pkts, nb_dq_pkts);
+ if (ret == -EDQUOT)
+ ring_state[port_id] = RING_OVERLOADED;
- else if (ret == -ENOBUFS) {
+ else if (ret == -ENOBUFS) {
- /* Return mbufs to the pool, effectively dropping packets */
- for (i = 0; i < nb_dq_pkts; i++)
- rte_pktmbuf_free(pkts[i]);
- }
- }
- }
+ /*
+ * Return mbufs to the pool,
+ * effectively dropping packets
+ */
+ for (i = 0; i < nb_dq_pkts; i++)
+ rte_pktmbuf_free(pkts[i]);
+ }
+ }
+ }
}
static void
@@ -265,108 +274,114 @@ send_stage(__attribute__((unused)) void *args)
{
uint16_t nb_dq_pkts;
- uint8_t port_id;
- uint8_t dest_port_id;
+ uint8_t port_id;
+ uint8_t dest_port_id;
- unsigned int lcore_id, previous_lcore_id;
+ unsigned int lcore_id, previous_lcore_id;
- struct rte_ring *tx;
- struct rte_mbuf *tx_pkts[MAX_PKT_QUOTA];
+ struct rte_ring *tx;
+ struct rte_mbuf *tx_pkts[MAX_PKT_QUOTA];
- lcore_id = rte_lcore_id();
- previous_lcore_id = get_previous_lcore_id(lcore_id);
+ lcore_id = rte_lcore_id();
+ previous_lcore_id = get_previous_lcore_id(lcore_id);
- RTE_LOG(INFO, USER1,
- "%s() started on core %u - processing packets from core %u\n",
- __func__, lcore_id, previous_lcore_id);
+ RTE_LOG(INFO, USER1,
+ "%s() started on core %u - processing packets from core %u\n",
+ __func__, lcore_id, previous_lcore_id);
- while (1) {
+ while (1) {
- /* Process each ring round robin style */
- for (port_id = 0; port_id < RTE_MAX_ETHPORTS; port_id++) {
+ /* Process each ring round robin style */
+ for (port_id = 0; port_id < RTE_MAX_ETHPORTS; port_id++) {
- if (!is_bit_set(port_id, portmask))
- continue;
+ if (!is_bit_set(port_id, portmask))
+ continue;
- dest_port_id = port_pairs[port_id];
- tx = rings[previous_lcore_id][port_id];
+ dest_port_id = port_pairs[port_id];
+ tx = rings[previous_lcore_id][port_id];
- if (rte_ring_empty(tx))
- continue;
+ if (rte_ring_empty(tx))
+ continue;
- /* Dequeue packets from tx and send them */
- nb_dq_pkts = (uint16_t) rte_ring_dequeue_burst(tx, (void *) tx_pkts, *quota);
- rte_eth_tx_burst(dest_port_id, 0, tx_pkts, nb_dq_pkts);
+ /* Dequeue packets from tx and send them */
+ nb_dq_pkts = (uint16_t) rte_ring_dequeue_burst(tx,
+ (void *) tx_pkts, *quota);
+ rte_eth_tx_burst(dest_port_id, 0, tx_pkts, nb_dq_pkts);
- /* TODO: Check if nb_dq_pkts == nb_tx_pkts? */
- }
- }
+ /* TODO: Check if nb_dq_pkts == nb_tx_pkts? */
+ }
+ }
}
int
main(int argc, char **argv)
{
- int ret;
- unsigned int lcore_id, master_lcore_id, last_lcore_id;
+ int ret;
+ unsigned int lcore_id, master_lcore_id, last_lcore_id;
- uint8_t port_id;
+ uint8_t port_id;
- rte_set_log_level(RTE_LOG_INFO);
+ rte_set_log_level(RTE_LOG_INFO);
- ret = rte_eal_init(argc, argv);
- if (ret < 0)
- rte_exit(EXIT_FAILURE, "Cannot initialize EAL\n");
+ ret = rte_eal_init(argc, argv);
+ if (ret < 0)
+ rte_exit(EXIT_FAILURE, "Cannot initialize EAL\n");
- argc -= ret;
- argv += ret;
+ argc -= ret;
+ argv += ret;
- init_dpdk();
- setup_shared_variables();
+ init_dpdk();
+ setup_shared_variables();
- *quota = 32;
- *low_watermark = 60 * RING_SIZE / 100;
+ *quota = 32;
+ *low_watermark = 60 * RING_SIZE / 100;
- last_lcore_id = get_last_lcore_id();
- master_lcore_id = rte_get_master_lcore();
+ last_lcore_id = get_last_lcore_id();
+ master_lcore_id = rte_get_master_lcore();
- /* Parse the application's arguments */
- ret = parse_qw_args(argc, argv);
- if (ret < 0)
- rte_exit(EXIT_FAILURE, "Invalid quota/watermark argument(s)\n");
+ /* Parse the application's arguments */
+ ret = parse_qw_args(argc, argv);
+ if (ret < 0)
+ rte_exit(EXIT_FAILURE, "Invalid quota/watermark argument(s)\n");
- /* Create a pool of mbuf to store packets */
- mbuf_pool = rte_pktmbuf_pool_create("mbuf_pool", MBUF_PER_POOL, 32, 0,
- MBUF_DATA_SIZE, rte_socket_id());
- if (mbuf_pool == NULL)
- rte_panic("%s\n", rte_strerror(rte_errno));
+ /* Create a pool of mbuf to store packets */
+ mbuf_pool = rte_pktmbuf_pool_create("mbuf_pool", MBUF_PER_POOL, 32, 0,
+ MBUF_DATA_SIZE, rte_socket_id());
+ if (mbuf_pool == NULL)
+ rte_panic("%s\n", rte_strerror(rte_errno));
- for (port_id = 0; port_id < RTE_MAX_ETHPORTS; port_id++)
- if (is_bit_set(port_id, portmask)) {
- configure_eth_port(port_id);
- init_ring(master_lcore_id, port_id);
- }
+ for (port_id = 0; port_id < RTE_MAX_ETHPORTS; port_id++)
+ if (is_bit_set(port_id, portmask)) {
+ configure_eth_port(port_id);
+ init_ring(master_lcore_id, port_id);
+ }
- pair_ports();
+ pair_ports();
- /* Start pipeline_connect() on all the available slave lcore but the last */
- for (lcore_id = 0 ; lcore_id < last_lcore_id; lcore_id++) {
- if (rte_lcore_is_enabled(lcore_id) && lcore_id != master_lcore_id) {
+ /*
+ * Start pipeline_connect() on all the available slave lcores
+ * but the last
+ */
+ for (lcore_id = 0 ; lcore_id < last_lcore_id; lcore_id++) {
+ if (rte_lcore_is_enabled(lcore_id) &&
+ lcore_id != master_lcore_id) {
- for (port_id = 0; port_id < RTE_MAX_ETHPORTS; port_id++)
- if (is_bit_set(port_id, portmask))
- init_ring(lcore_id, port_id);
+ for (port_id = 0; port_id < RTE_MAX_ETHPORTS; port_id++)
+ if (is_bit_set(port_id, portmask))
+ init_ring(lcore_id, port_id);
- /* typecast is a workaround for GCC 4.3 bug */
- rte_eal_remote_launch((int (*)(void *))pipeline_stage, NULL, lcore_id);
- }
- }
+ /* typecast is a workaround for GCC 4.3 bug */
+ rte_eal_remote_launch((int (*)(void *))pipeline_stage,
+ NULL, lcore_id);
+ }
+ }
- /* Start send_stage() on the last slave core */
- /* typecast is a workaround for GCC 4.3 bug */
- rte_eal_remote_launch((int (*)(void *))send_stage, NULL, last_lcore_id);
+ /* Start send_stage() on the last slave core */
+ /* typecast is a workaround for GCC 4.3 bug */
+ rte_eal_remote_launch((int (*)(void *))send_stage, NULL, last_lcore_id);
- /* Start receive_stage() on the master core */
- receive_stage(NULL);
+ /* Start receive_stage() on the master core */
+ receive_stage(NULL);
- return 0;
+ return 0;
}
diff --git a/examples/quota_watermark/qw/main.h b/examples/quota_watermark/qw/main.h
index 6b36489..545ba42 100644
--- a/examples/quota_watermark/qw/main.h
+++ b/examples/quota_watermark/qw/main.h
@@ -37,8 +37,8 @@
#include "../include/conf.h"
enum ring_state {
- RING_READY,
- RING_OVERLOADED,
+ RING_READY,
+ RING_OVERLOADED,
};
extern int *quota;
@@ -53,7 +53,7 @@ extern struct rte_mempool *mbuf_pool;
static inline int
is_bit_set(int i, unsigned int mask)
{
- return (1 << i) & mask;
+ return (1 << i) & mask;
}
#endif /* _MAIN_H_ */
diff --git a/examples/quota_watermark/qwctl/commands.c b/examples/quota_watermark/qwctl/commands.c
index 5348dd3..036bf80 100644
--- a/examples/quota_watermark/qwctl/commands.c
+++ b/examples/quota_watermark/qwctl/commands.c
@@ -53,36 +53,36 @@
*/
struct cmd_help_tokens {
- cmdline_fixed_string_t verb;
+ cmdline_fixed_string_t verb;
};
cmdline_parse_token_string_t cmd_help_verb =
- TOKEN_STRING_INITIALIZER(struct cmd_help_tokens, verb, "help");
+ TOKEN_STRING_INITIALIZER(struct cmd_help_tokens, verb, "help");
static void
cmd_help_handler(__attribute__((unused)) void *parsed_result,
- struct cmdline *cl,
- __attribute__((unused)) void *data)
+ struct cmdline *cl,
+ __attribute__((unused)) void *data)
{
- cmdline_printf(cl, "Available commands:\n"
- "- help\n"
- "- set [ring_name|variable] <value>\n"
- "- show [ring_name|variable]\n"
- "\n"
- "Available variables:\n"
- "- low_watermark\n"
- "- quota\n"
- "- ring names follow the core%%u_port%%u format\n");
+ cmdline_printf(cl, "Available commands:\n"
+ "- help\n"
+ "- set [ring_name|variable] <value>\n"
+ "- show [ring_name|variable]\n"
+ "\n"
+ "Available variables:\n"
+ "- low_watermark\n"
+ "- quota\n"
+ "- ring names follow the core%%u_port%%u format\n");
}
cmdline_parse_inst_t cmd_help = {
- .f = cmd_help_handler,
- .data = NULL,
- .help_str = "show help",
- .tokens = {
- (void *) &cmd_help_verb,
- NULL,
- },
+ .f = cmd_help_handler,
+ .data = NULL,
+ .help_str = "show help",
+ .tokens = {
+ (void *) &cmd_help_verb,
+ NULL,
+ },
};
@@ -91,69 +91,74 @@ cmdline_parse_inst_t cmd_help = {
*/
struct cmd_set_tokens {
- cmdline_fixed_string_t verb;
- cmdline_fixed_string_t variable;
- uint32_t value;
+ cmdline_fixed_string_t verb;
+ cmdline_fixed_string_t variable;
+ uint32_t value;
};
cmdline_parse_token_string_t cmd_set_verb =
- TOKEN_STRING_INITIALIZER(struct cmd_set_tokens, verb, "set");
+ TOKEN_STRING_INITIALIZER(struct cmd_set_tokens, verb, "set");
cmdline_parse_token_string_t cmd_set_variable =
- TOKEN_STRING_INITIALIZER(struct cmd_set_tokens, variable, NULL);
+ TOKEN_STRING_INITIALIZER(struct cmd_set_tokens, variable, NULL);
cmdline_parse_token_num_t cmd_set_value =
- TOKEN_NUM_INITIALIZER(struct cmd_set_tokens, value, UINT32);
+ TOKEN_NUM_INITIALIZER(struct cmd_set_tokens, value, UINT32);
static void
cmd_set_handler(__attribute__((unused)) void *parsed_result,
- struct cmdline *cl,
- __attribute__((unused)) void *data)
+ struct cmdline *cl,
+ __attribute__((unused)) void *data)
{
- struct cmd_set_tokens *tokens = parsed_result;
- struct rte_ring *ring;
-
- if (!strcmp(tokens->variable, "quota")) {
-
- if (tokens->value > 0 && tokens->value <= MAX_PKT_QUOTA)
- *quota = tokens->value;
- else
- cmdline_printf(cl, "quota must be between 1 and %u\n", MAX_PKT_QUOTA);
- }
-
- else if (!strcmp(tokens->variable, "low_watermark")) {
-
- if (tokens->value <= 100)
- *low_watermark = tokens->value * RING_SIZE / 100;
- else
- cmdline_printf(cl, "low_watermark must be between 0%% and 100%%\n");
- }
-
- else {
-
- ring = rte_ring_lookup(tokens->variable);
- if (ring == NULL)
- cmdline_printf(cl, "Cannot find ring \"%s\"\n", tokens->variable);
- else
- if (tokens->value >= *low_watermark * 100 / RING_SIZE
- && tokens->value <= 100)
- rte_ring_set_water_mark(ring, tokens->value * RING_SIZE / 100);
- else
- cmdline_printf(cl, "ring high watermark must be between %u%% "
- "and 100%%\n", *low_watermark * 100 / RING_SIZE);
- }
+ struct cmd_set_tokens *tokens = parsed_result;
+ struct rte_ring *ring;
+
+ if (!strcmp(tokens->variable, "quota")) {
+
+ if (tokens->value > 0 && tokens->value <= MAX_PKT_QUOTA)
+ *quota = tokens->value;
+ else
+ cmdline_printf(cl, "quota must be between 1 and %u\n",
+ MAX_PKT_QUOTA);
+ }
+
+ else if (!strcmp(tokens->variable, "low_watermark")) {
+
+ if (tokens->value <= 100)
+ *low_watermark = tokens->value * RING_SIZE / 100;
+ else
+ cmdline_printf(cl,
+ "low_watermark must be between 0%% and 100%%\n");
+ }
+
+ else {
+
+ ring = rte_ring_lookup(tokens->variable);
+ if (ring == NULL)
+ cmdline_printf(cl, "Cannot find ring \"%s\"\n",
+ tokens->variable);
+ else
+ if (tokens->value >= *low_watermark * 100 / RING_SIZE
+ && tokens->value <= 100)
+ rte_ring_set_water_mark(ring,
+ tokens->value * RING_SIZE / 100);
+ else
+ cmdline_printf(cl,
+ "ring high watermark must be between %u%% and 100%%\n",
+ *low_watermark * 100 / RING_SIZE);
+ }
}
cmdline_parse_inst_t cmd_set = {
- .f = cmd_set_handler,
- .data = NULL,
- .help_str = "Set a variable value",
- .tokens = {
- (void *) &cmd_set_verb,
- (void *) &cmd_set_variable,
- (void *) &cmd_set_value,
- NULL,
- },
+ .f = cmd_set_handler,
+ .data = NULL,
+ .help_str = "Set a variable value",
+ .tokens = {
+ (void *) &cmd_set_verb,
+ (void *) &cmd_set_variable,
+ (void *) &cmd_set_value,
+ NULL,
+ },
};
@@ -162,56 +167,59 @@ cmdline_parse_inst_t cmd_set = {
*/
struct cmd_show_tokens {
- cmdline_fixed_string_t verb;
- cmdline_fixed_string_t variable;
+ cmdline_fixed_string_t verb;
+ cmdline_fixed_string_t variable;
};
cmdline_parse_token_string_t cmd_show_verb =
- TOKEN_STRING_INITIALIZER(struct cmd_show_tokens, verb, "show");
+ TOKEN_STRING_INITIALIZER(struct cmd_show_tokens, verb, "show");
cmdline_parse_token_string_t cmd_show_variable =
- TOKEN_STRING_INITIALIZER(struct cmd_show_tokens, variable, NULL);
+ TOKEN_STRING_INITIALIZER(struct cmd_show_tokens,
+ variable, NULL);
static void
cmd_show_handler(__attribute__((unused)) void *parsed_result,
- struct cmdline *cl,
- __attribute__((unused)) void *data)
+ struct cmdline *cl,
+ __attribute__((unused)) void *data)
{
- struct cmd_show_tokens *tokens = parsed_result;
- struct rte_ring *ring;
+ struct cmd_show_tokens *tokens = parsed_result;
+ struct rte_ring *ring;
- if (!strcmp(tokens->variable, "quota"))
- cmdline_printf(cl, "Global quota: %d\n", *quota);
+ if (!strcmp(tokens->variable, "quota"))
+ cmdline_printf(cl, "Global quota: %d\n", *quota);
- else if (!strcmp(tokens->variable, "low_watermark"))
- cmdline_printf(cl, "Global low_watermark: %u\n", *low_watermark);
+ else if (!strcmp(tokens->variable, "low_watermark"))
+ cmdline_printf(cl, "Global low_watermark: %u\n",
+ *low_watermark);
- else {
+ else {
- ring = rte_ring_lookup(tokens->variable);
- if (ring == NULL)
- cmdline_printf(cl, "Cannot find ring \"%s\"\n", tokens->variable);
- else
- rte_ring_dump(stdout, ring);
- }
+ ring = rte_ring_lookup(tokens->variable);
+ if (ring == NULL)
+ cmdline_printf(cl, "Cannot find ring \"%s\"\n",
+ tokens->variable);
+ else
+ rte_ring_dump(stdout, ring);
+ }
}
cmdline_parse_inst_t cmd_show = {
- .f = cmd_show_handler,
- .data = NULL,
- .help_str = "Show a variable value",
- .tokens = {
- (void *) &cmd_show_verb,
- (void *) &cmd_show_variable,
- NULL,
- },
+ .f = cmd_show_handler,
+ .data = NULL,
+ .help_str = "Show a variable value",
+ .tokens = {
+ (void *) &cmd_show_verb,
+ (void *) &cmd_show_variable,
+ NULL,
+ },
};
cmdline_parse_ctx_t qwctl_ctx[] = {
- (cmdline_parse_inst_t *)&cmd_help,
- (cmdline_parse_inst_t *)&cmd_set,
- (cmdline_parse_inst_t *)&cmd_show,
- NULL,
+ (cmdline_parse_inst_t *)&cmd_help,
+ (cmdline_parse_inst_t *)&cmd_set,
+ (cmdline_parse_inst_t *)&cmd_show,
+ NULL,
};
diff --git a/examples/quota_watermark/qwctl/qwctl.c b/examples/quota_watermark/qwctl/qwctl.c
index 29c501c..3a85cc3 100644
--- a/examples/quota_watermark/qwctl/qwctl.c
+++ b/examples/quota_watermark/qwctl/qwctl.c
@@ -60,35 +60,35 @@ unsigned int *low_watermark;
static void
setup_shared_variables(void)
{
- const struct rte_memzone *qw_memzone;
+ const struct rte_memzone *qw_memzone;
- qw_memzone = rte_memzone_lookup(QUOTA_WATERMARK_MEMZONE_NAME);
- if (qw_memzone == NULL)
- rte_exit(EXIT_FAILURE, "Couldn't find memzone\n");
+ qw_memzone = rte_memzone_lookup(QUOTA_WATERMARK_MEMZONE_NAME);
+ if (qw_memzone == NULL)
+ rte_exit(EXIT_FAILURE, "Couldn't find memzone\n");
- quota = qw_memzone->addr;
- low_watermark = (unsigned int *) qw_memzone->addr + 1;
+ quota = qw_memzone->addr;
+ low_watermark = (unsigned int *) qw_memzone->addr + 1;
}
int main(int argc, char **argv)
{
- int ret;
- struct cmdline *cl;
+ int ret;
+ struct cmdline *cl;
- rte_set_log_level(RTE_LOG_INFO);
+ rte_set_log_level(RTE_LOG_INFO);
- ret = rte_eal_init(argc, argv);
- if (ret < 0)
- rte_exit(EXIT_FAILURE, "Cannot initialize EAL\n");
+ ret = rte_eal_init(argc, argv);
+ if (ret < 0)
+ rte_exit(EXIT_FAILURE, "Cannot initialize EAL\n");
- setup_shared_variables();
+ setup_shared_variables();
- cl = cmdline_stdin_new(qwctl_ctx, "qwctl> ");
- if (cl == NULL)
- rte_exit(EXIT_FAILURE, "Cannot create cmdline instance\n");
+ cl = cmdline_stdin_new(qwctl_ctx, "qwctl> ");
+ if (cl == NULL)
+ rte_exit(EXIT_FAILURE, "Cannot create cmdline instance\n");
- cmdline_interact(cl);
- cmdline_stdin_exit(cl);
+ cmdline_interact(cl);
+ cmdline_stdin_exit(cl);
- return 0;
+ return 0;
}
--
2.9.3
^ permalink raw reply [flat|nested] 15+ messages in thread
* [dpdk-dev] [PATCH v2 5/5] examples/quota_watermark: fix requirement for 2M pages
2017-02-21 16:52 [dpdk-dev] [PATCH 0/4] minor fixes and cleanup Bruce Richardson
` (8 preceding siblings ...)
2017-02-23 16:42 ` [dpdk-dev] [PATCH v2 4/5] examples/quota_watermark: correct code indentation Bruce Richardson
@ 2017-02-23 16:42 ` Bruce Richardson
9 siblings, 0 replies; 15+ messages in thread
From: Bruce Richardson @ 2017-02-23 16:42 UTC (permalink / raw)
To: dev; +Cc: Bruce Richardson, stable
The sample app was forcing the shared memory block for high/low
watermarks to be placed in a memzone on 2M pages. This prevented it
from running on systems with just 1G pages, so remove the flag forcing
2M pages.
Fixes: 1d6c3ee3321a ("examples/quota_watermark: initial import")
CC: stable@dpdk.org
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
examples/quota_watermark/qw/init.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/examples/quota_watermark/qw/init.c b/examples/quota_watermark/qw/init.c
index e941ce8..95a9f94 100644
--- a/examples/quota_watermark/qw/init.c
+++ b/examples/quota_watermark/qw/init.c
@@ -168,7 +168,7 @@ setup_shared_variables(void)
const struct rte_memzone *qw_memzone;
qw_memzone = rte_memzone_reserve(QUOTA_WATERMARK_MEMZONE_NAME,
- 2 * sizeof(int), rte_socket_id(), RTE_MEMZONE_2MB);
+ 2 * sizeof(int), rte_socket_id(), 0);
if (qw_memzone == NULL)
rte_exit(EXIT_FAILURE, "%s\n", rte_strerror(rte_errno));
--
2.9.3
^ permalink raw reply [flat|nested] 15+ messages in thread