};
struct pmd_devargs {
- unsigned num_of_queue;
+ unsigned int num_of_queue;
struct devargs_queue {
pcap_dumper_t *dumper;
pcap_t *pcap;
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,
static uint16_t
eth_pcap_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
{
- unsigned i;
+ unsigned int i;
struct pcap_pkthdr header;
const u_char *packet;
struct rte_mbuf *mbuf;
packet = pcap_next(pcap_q->pcap, &header);
if (unlikely(packet == NULL))
break;
- else
- mbuf = rte_pktmbuf_alloc(pcap_q->mb_pool);
+
+ mbuf = rte_pktmbuf_alloc(pcap_q->mb_pool);
if (unlikely(mbuf == NULL))
break;
/* Now get the space available for data in the mbuf */
- buf_size = (uint16_t)(rte_pktmbuf_data_room_size(pcap_q->mb_pool) -
- RTE_PKTMBUF_HEADROOM);
+ buf_size = rte_pktmbuf_data_room_size(pcap_q->mb_pool) -
+ RTE_PKTMBUF_HEADROOM;
if (header.caplen <= buf_size) {
- /* pcap packet will fit in the mbuf, go ahead and copy */
+ /* pcap packet will fit in the mbuf, can copy it */
rte_memcpy(rte_pktmbuf_mtod(mbuf, void *), packet,
header.caplen);
mbuf->data_len = (uint16_t)header.caplen;
static uint16_t
eth_pcap_tx_dumper(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
{
- unsigned i;
+ unsigned int i;
struct rte_mbuf *mbuf;
struct pcap_tx_queue *dumper_q = queue;
uint16_t num_tx = 0;
if (dumper_q->dumper == NULL || nb_pkts == 0)
return 0;
- /* writes the nb_pkts packets to the previously opened pcap file dumper */
+ /* writes the nb_pkts packets to the previously opened pcap file
+ * dumper */
for (i = 0; i < nb_pkts; i++) {
mbuf = bufs[i];
calculate_timestamp(&header.ts);
tx_pcap_data);
} else {
RTE_LOG(ERR, PMD,
- "Dropping PCAP packet. "
- "Size (%d) > max jumbo size (%d).\n",
+ "Dropping PCAP packet. Size (%d) > max jumbo size (%d).\n",
mbuf->pkt_len,
ETHER_MAX_JUMBO_FRAME_LEN);
static uint16_t
eth_pcap_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
{
- unsigned i;
+ unsigned int i;
int ret;
struct rte_mbuf *mbuf;
struct pcap_tx_queue *tx_queue = queue;
tx_pcap_data, mbuf->pkt_len);
} else {
RTE_LOG(ERR, PMD,
- "Dropping PCAP packet. "
- "Size (%d) > max jumbo size (%d).\n",
+ "Dropping PCAP packet. Size (%d) > max jumbo size (%d).\n",
mbuf->pkt_len,
ETHER_MAX_JUMBO_FRAME_LEN);
* with pcap_dump_open(). We create big enough an Ethernet
* pcap holder.
*/
- if ((tx_pcap = pcap_open_dead(DLT_EN10MB, RTE_ETH_PCAP_SNAPSHOT_LEN))
- == NULL) {
+ tx_pcap = pcap_open_dead(DLT_EN10MB, RTE_ETH_PCAP_SNAPSHOT_LEN);
+ if (tx_pcap == NULL) {
RTE_LOG(ERR, PMD, "Couldn't create dead pcap\n");
return -1;
}
/* The dumper is created using the previous pcap_t reference */
- if ((*dumper = pcap_dump_open(tx_pcap, pcap_filename)) == NULL) {
+ *dumper = pcap_dump_open(tx_pcap, pcap_filename);
+ if (*dumper == NULL) {
RTE_LOG(ERR, PMD, "Couldn't open %s for writing.\n",
pcap_filename);
return -1;
static int
open_single_rx_pcap(const char *pcap_filename, pcap_t **pcap)
{
- if ((*pcap = pcap_open_offline(pcap_filename, errbuf)) == NULL) {
- RTE_LOG(ERR, PMD, "Couldn't open %s: %s\n", pcap_filename, errbuf);
+ *pcap = pcap_open_offline(pcap_filename, errbuf);
+ if (*pcap == NULL) {
+ RTE_LOG(ERR, PMD, "Couldn't open %s: %s\n", pcap_filename,
+ errbuf);
return -1;
}
static int
eth_dev_start(struct rte_eth_dev *dev)
{
- unsigned i;
+ unsigned int i;
struct pmd_internals *internals = dev->data->dev_private;
struct pcap_tx_queue *tx;
struct pcap_rx_queue *rx;
for (i = 0; i < dev->data->nb_tx_queues; i++) {
tx = &internals->tx_queue[i];
- if (!tx->dumper && strcmp(tx->type, ETH_PCAP_TX_PCAP_ARG) == 0) {
+ 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;
}
static void
eth_dev_stop(struct rte_eth_dev *dev)
{
- unsigned i;
+ unsigned int i;
struct pmd_internals *internals = dev->data->dev_private;
struct pcap_tx_queue *tx;
struct pcap_rx_queue *rx;
static void
eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
{
- unsigned i;
+ unsigned int i;
unsigned long rx_packets_total = 0, rx_bytes_total = 0;
unsigned long tx_packets_total = 0, tx_bytes_total = 0;
unsigned long tx_packets_err_total = 0;
static void
eth_stats_reset(struct rte_eth_dev *dev)
{
- unsigned i;
+ unsigned int i;
struct pmd_internals *internal = dev->data->dev_private;
for (i = 0; i < dev->data->nb_rx_queues; i++) {
unsigned int socket_id __rte_unused,
const struct rte_eth_txconf *tx_conf __rte_unused)
{
-
struct pmd_internals *internals = dev->data->dev_private;
dev->data->tx_queues[tx_queue_id] = &internals->tx_queue[tx_queue_id];
static int
open_rx_pcap(const char *key, const char *value, void *extra_args)
{
- unsigned i;
+ unsigned int i;
const char *pcap_filename = value;
struct pmd_devargs *rx = extra_args;
pcap_t *pcap = NULL;
static int
open_tx_pcap(const char *key, const char *value, void *extra_args)
{
- unsigned i;
+ unsigned int i;
const char *pcap_filename = value;
struct pmd_devargs *dumpers = extra_args;
pcap_dumper_t *dumper;
static inline int
open_rx_iface(const char *key, const char *value, void *extra_args)
{
- unsigned i;
+ unsigned int i;
const char *iface = value;
struct pmd_devargs *rx = extra_args;
pcap_t *pcap = NULL;
static int
open_tx_iface(const char *key, const char *value, void *extra_args)
{
- unsigned i;
+ unsigned int i;
const char *iface = value;
struct pmd_devargs *tx = extra_args;
pcap_t *pcap;
}
static int
-pmd_init_internals(const char *name, const unsigned nb_rx_queues,
- const unsigned nb_tx_queues, struct pmd_internals **internals,
+pmd_init_internals(const char *name, const unsigned int nb_rx_queues,
+ const unsigned int nb_tx_queues,
+ struct pmd_internals **internals,
struct rte_eth_dev **eth_dev)
{
struct rte_eth_dev_data *data = NULL;
static int
eth_from_pcaps_common(const char *name, struct pmd_devargs *rx_queues,
- const unsigned nb_rx_queues, struct pmd_devargs *tx_queues,
- const unsigned nb_tx_queues, struct rte_kvargs *kvlist,
+ const unsigned int nb_rx_queues, struct pmd_devargs *tx_queues,
+ const unsigned int nb_tx_queues, struct rte_kvargs *kvlist,
struct pmd_internals **internals, struct rte_eth_dev **eth_dev)
{
struct rte_kvargs_pair *pair = NULL;
- unsigned k_idx;
- unsigned i;
+ unsigned int k_idx;
+ unsigned int i;
/* do some parameter checking */
if (rx_queues == NULL && nb_rx_queues > 0)
static int
eth_from_pcaps(const char *name, struct pmd_devargs *rx_queues,
- const unsigned nb_rx_queues, struct pmd_devargs *tx_queues,
- const unsigned nb_tx_queues, struct rte_kvargs *kvlist,
+ const unsigned int nb_rx_queues, struct pmd_devargs *tx_queues,
+ const unsigned int nb_tx_queues, struct rte_kvargs *kvlist,
int single_iface, unsigned int using_dumpers)
{
struct pmd_internals *internals = NULL;