DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ferruh Yigit <ferruh.yigit@intel.com>
To: dev@dpdk.org
Cc: Nicolas Pernas Maradei <nicolas.pernas.maradei@emutex.com>
Subject: [dpdk-dev] [RFC 20/21] net/pcap: coding convention updates
Date: Thu, 21 Jul 2016 18:22:59 +0100	[thread overview]
Message-ID: <1469121780-26099-21-git-send-email-ferruh.yigit@intel.com> (raw)
In-Reply-To: <1469121780-26099-1-git-send-email-ferruh.yigit@intel.com>

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

diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c
index f3df372..552a1de 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"
@@ -112,7 +113,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,
@@ -122,15 +125,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;
@@ -170,7 +170,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;
@@ -178,9 +178,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;
@@ -233,6 +231,7 @@ eth_pcap_rx(void *queue,
 	}
 	pcap_q->rx_stat.pkts += num_rx;
 	pcap_q->rx_stat.bytes += rx_bytes;
+
 	return num_rx;
 }
 
@@ -251,9 +250,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;
@@ -306,6 +303,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;
 }
 
@@ -313,9 +311,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;
@@ -332,14 +328,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. "
@@ -362,6 +357,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;
 }
 
@@ -457,9 +453,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;
 		}
@@ -475,17 +469,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;
 }
 
@@ -550,6 +542,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;
@@ -561,8 +554,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;
@@ -600,10 +592,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;
@@ -638,9 +632,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;
 }
 
@@ -653,13 +649,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,
@@ -916,7 +914,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;
@@ -1025,6 +1023,7 @@ create_eth:
 
 free_kvlist:
 	rte_kvargs_free(kvlist);
+
 	return ret;
 }
 
-- 
2.7.4

  parent reply	other threads:[~2016-07-21 17:25 UTC|newest]

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

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=1469121780-26099-21-git-send-email-ferruh.yigit@intel.com \
    --to=ferruh.yigit@intel.com \
    --cc=dev@dpdk.org \
    --cc=nicolas.pernas.maradei@emutex.com \
    /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).