DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ferruh Yigit <ferruh.yigit@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 20/22] net/pcap: coding convention updates
Date: Fri, 26 Aug 2016 12:17:57 +0100	[thread overview]
Message-ID: <1472210279-8286-21-git-send-email-ferruh.yigit@intel.com> (raw)
In-Reply-To: <1472210279-8286-1-git-send-email-ferruh.yigit@intel.com>

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 drivers/net/pcap/rte_eth_pcap.c | 64 ++++++++++++++++++++---------------------
 1 file changed, 31 insertions(+), 33 deletions(-)

diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c
index 5a2a194..1716512 100644
--- a/drivers/net/pcap/rte_eth_pcap.c
+++ b/drivers/net/pcap/rte_eth_pcap.c
@@ -49,6 +49,7 @@
 #define RTE_ETH_PCAP_SNAPLEN ETHER_MAX_JUMBO_FRAME_LEN
 #define RTE_ETH_PCAP_PROMISC 1
 #define RTE_ETH_PCAP_TIMEOUT -1
+
 #define ETH_PCAP_RX_PCAP_ARG  "rx_pcap"
 #define ETH_PCAP_TX_PCAP_ARG  "tx_pcap"
 #define ETH_PCAP_RX_IFACE_ARG "rx_iface"
@@ -114,7 +115,9 @@ static const char *valid_arguments[] = {
 	NULL
 };
 
-static struct ether_addr eth_addr = { .addr_bytes = { 0, 0, 0, 0x1, 0x2, 0x3 } };
+static struct ether_addr eth_addr = {
+	.addr_bytes = { 0, 0, 0, 0x1, 0x2, 0x3 }
+};
 static const char *drivername = "Pcap PMD";
 static struct rte_eth_link pmd_link = {
 		.link_speed = ETH_SPEED_NUM_10G,
@@ -124,15 +127,12 @@ static struct rte_eth_link pmd_link = {
 };
 
 static int
-eth_pcap_rx_jumbo(struct rte_mempool *mb_pool,
-		  struct rte_mbuf *mbuf,
-		  const u_char *data,
-		  uint16_t data_len)
+eth_pcap_rx_jumbo(struct rte_mempool *mb_pool, struct rte_mbuf *mbuf,
+		const u_char *data, uint16_t data_len)
 {
-	struct rte_mbuf *m = mbuf;
-
 	/* Copy the first segment. */
 	uint16_t len = rte_pktmbuf_tailroom(mbuf);
+	struct rte_mbuf *m = mbuf;
 
 	rte_memcpy(rte_pktmbuf_append(mbuf, len), data, len);
 	data_len -= len;
@@ -172,7 +172,7 @@ eth_pcap_gather_data(unsigned char *data, struct rte_mbuf *mbuf)
 
 	while (mbuf) {
 		rte_memcpy(data + data_len, rte_pktmbuf_mtod(mbuf, void *),
-			   mbuf->data_len);
+			mbuf->data_len);
 
 		data_len += mbuf->data_len;
 		mbuf = mbuf->next;
@@ -180,9 +180,7 @@ eth_pcap_gather_data(unsigned char *data, struct rte_mbuf *mbuf)
 }
 
 static uint16_t
-eth_pcap_rx(void *queue,
-		struct rte_mbuf **bufs,
-		uint16_t nb_pkts)
+eth_pcap_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 {
 	unsigned i;
 	struct pcap_pkthdr header;
@@ -235,6 +233,7 @@ eth_pcap_rx(void *queue,
 	}
 	pcap_q->rx_stat.pkts += num_rx;
 	pcap_q->rx_stat.bytes += rx_bytes;
+
 	return num_rx;
 }
 
@@ -253,9 +252,7 @@ calculate_timestamp(struct timeval *ts) {
  * Callback to handle writing packets to a pcap file.
  */
 static uint16_t
-eth_pcap_tx_dumper(void *queue,
-		struct rte_mbuf **bufs,
-		uint16_t nb_pkts)
+eth_pcap_tx_dumper(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 {
 	unsigned i;
 	struct rte_mbuf *mbuf;
@@ -308,6 +305,7 @@ eth_pcap_tx_dumper(void *queue,
 	dumper_q->tx_stat.pkts += num_tx;
 	dumper_q->tx_stat.bytes += tx_bytes;
 	dumper_q->tx_stat.err_pkts += nb_pkts - num_tx;
+
 	return num_tx;
 }
 
@@ -315,9 +313,7 @@ eth_pcap_tx_dumper(void *queue,
  * Callback to handle sending packets through a real NIC.
  */
 static uint16_t
-eth_pcap_tx(void *queue,
-		struct rte_mbuf **bufs,
-		uint16_t nb_pkts)
+eth_pcap_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 {
 	unsigned i;
 	int ret;
@@ -334,14 +330,13 @@ eth_pcap_tx(void *queue,
 
 		if (likely(mbuf->nb_segs == 1)) {
 			ret = pcap_sendpacket(tx_queue->pcap,
-					      rte_pktmbuf_mtod(mbuf, u_char *),
-					      mbuf->pkt_len);
+					rte_pktmbuf_mtod(mbuf, u_char *),
+					mbuf->pkt_len);
 		} else {
 			if (mbuf->pkt_len <= ETHER_MAX_JUMBO_FRAME_LEN) {
 				eth_pcap_gather_data(tx_pcap_data, mbuf);
 				ret = pcap_sendpacket(tx_queue->pcap,
-						      tx_pcap_data,
-						      mbuf->pkt_len);
+						tx_pcap_data, mbuf->pkt_len);
 			} else {
 				RTE_LOG(ERR, PMD,
 					"Dropping PCAP packet. "
@@ -364,6 +359,7 @@ eth_pcap_tx(void *queue,
 	tx_queue->tx_stat.pkts += num_tx;
 	tx_queue->tx_stat.bytes += tx_bytes;
 	tx_queue->tx_stat.err_pkts += nb_pkts - num_tx;
+
 	return num_tx;
 }
 
@@ -459,9 +455,7 @@ eth_dev_start(struct rte_eth_dev *dev)
 		if (!tx->dumper && strcmp(tx->type, ETH_PCAP_TX_PCAP_ARG) == 0) {
 			if (open_single_tx_pcap(tx->name, &tx->dumper) < 0)
 				return -1;
-		}
-
-		else if (!tx->pcap && strcmp(tx->type, ETH_PCAP_TX_IFACE_ARG) == 0) {
+		} else if (!tx->pcap && strcmp(tx->type, ETH_PCAP_TX_IFACE_ARG) == 0) {
 			if (open_single_iface(tx->name, &tx->pcap) < 0)
 				return -1;
 		}
@@ -477,17 +471,15 @@ eth_dev_start(struct rte_eth_dev *dev)
 		if (strcmp(rx->type, ETH_PCAP_RX_PCAP_ARG) == 0) {
 			if (open_single_rx_pcap(rx->name, &rx->pcap) < 0)
 				return -1;
-		}
-
-		else if (strcmp(rx->type, ETH_PCAP_RX_IFACE_ARG) == 0) {
+		} else if (strcmp(rx->type, ETH_PCAP_RX_IFACE_ARG) == 0) {
 			if (open_single_iface(rx->name, &rx->pcap) < 0)
 				return -1;
 		}
 	}
 
 status_up:
-
 	dev->data->dev_link.link_status = ETH_LINK_UP;
+
 	return 0;
 }
 
@@ -552,6 +544,7 @@ eth_dev_info(struct rte_eth_dev *dev,
 		struct rte_eth_dev_info *dev_info)
 {
 	struct pmd_internals *internals = dev->data->dev_private;
+
 	dev_info->driver_name = drivername;
 	dev_info->if_index = internals->if_index;
 	dev_info->max_mac_addrs = 1;
@@ -563,8 +556,7 @@ eth_dev_info(struct rte_eth_dev *dev,
 }
 
 static void
-eth_stats_get(struct rte_eth_dev *dev,
-		struct rte_eth_stats *stats)
+eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 {
 	unsigned i;
 	unsigned long rx_packets_total = 0, rx_bytes_total = 0;
@@ -602,10 +594,12 @@ eth_stats_reset(struct rte_eth_dev *dev)
 {
 	unsigned i;
 	struct pmd_internals *internal = dev->data->dev_private;
+
 	for (i = 0; i < dev->data->nb_rx_queues; i++) {
 		internal->rx_queue[i].rx_stat.pkts = 0;
 		internal->rx_queue[i].rx_stat.bytes = 0;
 	}
+
 	for (i = 0; i < dev->data->nb_tx_queues; i++) {
 		internal->tx_queue[i].tx_stat.pkts = 0;
 		internal->tx_queue[i].tx_stat.bytes = 0;
@@ -640,9 +634,11 @@ eth_rx_queue_setup(struct rte_eth_dev *dev,
 {
 	struct pmd_internals *internals = dev->data->dev_private;
 	struct pcap_rx_queue *pcap_q = &internals->rx_queue[rx_queue_id];
+
 	pcap_q->mb_pool = mb_pool;
 	dev->data->rx_queues[rx_queue_id] = pcap_q;
 	pcap_q->in_port = dev->data->port_id;
+
 	return 0;
 }
 
@@ -655,13 +651,15 @@ eth_tx_queue_setup(struct rte_eth_dev *dev,
 {
 
 	struct pmd_internals *internals = dev->data->dev_private;
+
 	dev->data->tx_queues[tx_queue_id] = &internals->tx_queue[tx_queue_id];
+
 	return 0;
 }
 
 static const struct eth_dev_ops ops = {
 	.dev_start = eth_dev_start,
-	.dev_stop =	eth_dev_stop,
+	.dev_stop = eth_dev_stop,
 	.dev_close = eth_dev_close,
 	.dev_configure = eth_dev_configure,
 	.dev_infos_get = eth_dev_info,
@@ -918,7 +916,7 @@ rte_eth_from_pcaps(const char *name, struct pmd_devargs *rx_queues,
 	if (ret < 0)
 		return ret;
 
-	/* store wether we are using a single interface for rx/tx or not */
+	/* store weather we are using a single interface for rx/tx or not */
 	internals->single_iface = single_iface;
 
 	eth_dev->rx_pkt_burst = eth_pcap_rx;
@@ -931,7 +929,6 @@ rte_eth_from_pcaps(const char *name, struct pmd_devargs *rx_queues,
 	return 0;
 }
 
-
 static int
 rte_pmd_pcap_devinit(const char *name, const char *params)
 {
@@ -1027,6 +1024,7 @@ create_eth:
 
 free_kvlist:
 	rte_kvargs_free(kvlist);
+
 	return ret;
 }
 
-- 
2.7.4

  parent reply	other threads:[~2016-08-26 11:25 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-26 11:17 [dpdk-dev] [PATCH 00/22] pcap pmd improvements Ferruh Yigit
2016-08-26 11:17 ` [dpdk-dev] [PATCH 01/22] net/pcap: convert config option to a macro Ferruh Yigit
2016-08-26 11:17 ` [dpdk-dev] [PATCH 02/22] net/pcap: use macros for param string Ferruh Yigit
2016-08-26 11:17 ` [dpdk-dev] [PATCH 03/22] net/pcap: reorganize private structs Ferruh Yigit
2016-08-26 11:17 ` [dpdk-dev] [PATCH 04/22] net/pcap: add checks for max queue number Ferruh Yigit
2016-08-26 11:17 ` [dpdk-dev] [PATCH 05/22] net/pcap: update function to reuse it Ferruh Yigit
2016-08-26 11:17 ` [dpdk-dev] [PATCH 06/22] net/pcap: don't carry numa_node argument Ferruh Yigit
2016-08-26 11:17 ` [dpdk-dev] [PATCH 07/22] net/pcap: don't carry kvlist argument Ferruh Yigit
2016-08-26 11:17 ` [dpdk-dev] [PATCH 08/22] net/pcap: move comment to correct place Ferruh Yigit
2016-08-26 11:17 ` [dpdk-dev] [PATCH 09/22] net/pcap: remove duplicated max queue number check Ferruh Yigit
2016-08-26 11:17 ` [dpdk-dev] [PATCH 10/22] net/pcap: use single_iface variable instead of hardcoded Ferruh Yigit
2016-08-26 11:17 ` [dpdk-dev] [PATCH 11/22] net/pcap: group stats related fields into a struct Ferruh Yigit
2016-08-26 11:17 ` [dpdk-dev] [PATCH 12/22] net/pcap: make const array static Ferruh Yigit
2016-08-26 11:17 ` [dpdk-dev] [PATCH 13/22] net/pcap: reorder header files Ferruh Yigit
2016-08-26 11:17 ` [dpdk-dev] [PATCH 14/22] net/pcap: reorder functions Ferruh Yigit
2016-08-26 11:17 ` [dpdk-dev] [PATCH 15/22] net/pcap: update how single iface handled Ferruh Yigit
2016-08-26 11:17 ` [dpdk-dev] [PATCH 16/22] net/pcap: remove unnecessary check Ferruh Yigit
2016-08-26 11:17 ` [dpdk-dev] [PATCH 17/22] net/pcap: remove redundant assignment Ferruh Yigit
2016-08-26 11:17 ` [dpdk-dev] [PATCH 18/22] net/pcap: simplify function Ferruh Yigit
2016-08-26 11:17 ` [dpdk-dev] [PATCH 19/22] net/pcap: fix missing Tx iface assignment Ferruh Yigit
2016-08-26 11:17 ` Ferruh Yigit [this message]
2016-08-26 11:17 ` [dpdk-dev] [PATCH 21/22] net/pcap: remove rte prefix from static functions Ferruh Yigit
2016-08-26 11:17 ` [dpdk-dev] [PATCH 22/22] net/pcap: fix checkpatch warnings Ferruh Yigit
2016-08-26 17:38 ` [dpdk-dev] [PATCH 00/22] pcap pmd improvements Stephen Hemminger
2016-09-19 16:42   ` Bruce Richardson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1472210279-8286-21-git-send-email-ferruh.yigit@intel.com \
    --to=ferruh.yigit@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).