git.droids-corp.org
/
dpdk.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
net/i40e: fix Rx data segment buffer length
[dpdk.git]
/
drivers
/
net
/
af_packet
/
rte_eth_af_packet.c
diff --git
a/drivers/net/af_packet/rte_eth_af_packet.c
b/drivers/net/af_packet/rte_eth_af_packet.c
index
5715dcb
..
9a47852
100644
(file)
--- a/
drivers/net/af_packet/rte_eth_af_packet.c
+++ b/
drivers/net/af_packet/rte_eth_af_packet.c
@@
-38,6
+38,7
@@
#include <rte_mbuf.h>
#include <rte_ethdev.h>
#include <rte_mbuf.h>
#include <rte_ethdev.h>
+#include <rte_ethdev_vdev.h>
#include <rte_malloc.h>
#include <rte_kvargs.h>
#include <rte_vdev.h>
#include <rte_malloc.h>
#include <rte_kvargs.h>
#include <rte_vdev.h>
@@
-161,6
+162,12
@@
eth_af_packet_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
pbuf = (uint8_t *) ppd + ppd->tp_mac;
memcpy(rte_pktmbuf_mtod(mbuf, void *), pbuf, rte_pktmbuf_data_len(mbuf));
pbuf = (uint8_t *) ppd + ppd->tp_mac;
memcpy(rte_pktmbuf_mtod(mbuf, void *), pbuf, rte_pktmbuf_data_len(mbuf));
+ /* check for vlan info */
+ if (ppd->tp_status & TP_STATUS_VLAN_VALID) {
+ mbuf->vlan_tci = ppd->tp_vlan_tci;
+ mbuf->ol_flags |= (PKT_RX_VLAN_PKT | PKT_RX_VLAN_STRIPPED);
+ }
+
/* release incoming frame and advance ring buffer */
ppd->tp_status = TP_STATUS_KERNEL;
if (++framenum >= framecount)
/* release incoming frame and advance ring buffer */
ppd->tp_status = TP_STATUS_KERNEL;
if (++framenum >= framecount)
@@
-214,6
+221,14
@@
eth_af_packet_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
continue;
}
continue;
}
+ /* insert vlan info if necessary */
+ if (mbuf->ol_flags & PKT_TX_VLAN_PKT) {
+ if (rte_vlan_insert(&mbuf)) {
+ rte_pktmbuf_free(mbuf);
+ continue;
+ }
+ }
+
/* point at the next incoming frame */
if ((ppd->tp_status != TP_STATUS_AVAILABLE) &&
(poll(&pfd, 1, -1) < 0))
/* point at the next incoming frame */
if ((ppd->tp_status != TP_STATUS_AVAILABLE) &&
(poll(&pfd, 1, -1) < 0))
@@
-237,8
+252,11
@@
eth_af_packet_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
}
/* kick-off transmits */
}
/* kick-off transmits */
- if (sendto(pkt_q->sockfd, NULL, 0, MSG_DONTWAIT, NULL, 0) == -1)
- num_tx = 0; /* error sending -- no packets transmitted */
+ if (sendto(pkt_q->sockfd, NULL, 0, MSG_DONTWAIT, NULL, 0) == -1) {
+ /* error sending -- no packets transmitted */
+ num_tx = 0;
+ num_tx_bytes = 0;
+ }
pkt_q->framenum = framenum;
pkt_q->tx_pkts += num_tx;
pkt_q->framenum = framenum;
pkt_q->tx_pkts += num_tx;
@@
-395,7
+413,7
@@
eth_rx_queue_setup(struct rte_eth_dev *dev,
if (data_size > buf_size) {
RTE_LOG(ERR, PMD,
"%s: %d bytes will not fit in mbuf (%d bytes)\n",
if (data_size > buf_size) {
RTE_LOG(ERR, PMD,
"%s: %d bytes will not fit in mbuf (%d bytes)\n",
- dev->d
ata
->name, data_size, buf_size);
+ dev->d
evice
->name, data_size, buf_size);
return -ENOMEM;
}
return -ENOMEM;
}
@@
-437,7
+455,7
@@
eth_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
if (s < 0)
return -EINVAL;
if (s < 0)
return -EINVAL;
- s
trncpy(ifr.ifr_name, internals->if_name, IFNAMSIZ
);
+ s
nprintf(ifr.ifr_name, IFNAMSIZ, "%s", internals->if_name
);
ret = ioctl(s, SIOCSIFMTU, &ifr);
close(s);
ret = ioctl(s, SIOCSIFMTU, &ifr);
close(s);
@@
-457,7
+475,7
@@
eth_dev_change_flags(char *if_name, uint32_t flags, uint32_t mask)
if (s < 0)
return;
if (s < 0)
return;
- s
trncpy(ifr.ifr_name, if_name, IFNAMSIZ
);
+ s
nprintf(ifr.ifr_name, IFNAMSIZ, "%s", if_name
);
if (ioctl(s, SIOCGIFFLAGS, &ifr) < 0)
goto out;
ifr.ifr_flags &= mask;
if (ioctl(s, SIOCGIFFLAGS, &ifr) < 0)
goto out;
ifr.ifr_flags &= mask;
@@
-525,18
+543,19
@@
open_packet_iface(const char *key __rte_unused,
static struct rte_vdev_driver pmd_af_packet_drv;
static int
static struct rte_vdev_driver pmd_af_packet_drv;
static int
-rte_pmd_init_internals(
const char *name
,
+rte_pmd_init_internals(
struct rte_vdev_device *dev
,
const int sockfd,
const unsigned nb_queues,
unsigned int blocksize,
unsigned int blockcnt,
unsigned int framesize,
unsigned int framecnt,
const int sockfd,
const unsigned nb_queues,
unsigned int blocksize,
unsigned int blockcnt,
unsigned int framesize,
unsigned int framecnt,
- const unsigned numa_node,
struct pmd_internals **internals,
struct rte_eth_dev **eth_dev,
struct rte_kvargs *kvlist)
{
struct pmd_internals **internals,
struct rte_eth_dev **eth_dev,
struct rte_kvargs *kvlist)
{
+ const char *name = rte_vdev_device_name(dev);
+ const unsigned int numa_node = dev->device.numa_node;
struct rte_eth_dev_data *data = NULL;
struct rte_kvargs_pair *pair = NULL;
struct ifreq ifr;
struct rte_eth_dev_data *data = NULL;
struct rte_kvargs_pair *pair = NULL;
struct ifreq ifr;
@@
-549,7
+568,12
@@
rte_pmd_init_internals(const char *name,
int rc, tpver, discard;
int qsockfd = -1;
unsigned int i, q, rdsize;
int rc, tpver, discard;
int qsockfd = -1;
unsigned int i, q, rdsize;
- int fanout_arg __rte_unused, bypass __rte_unused;
+#if defined(PACKET_FANOUT)
+ int fanout_arg;
+#endif
+#if defined(PACKET_QDISC_BYPASS)
+ int bypass;
+#endif
for (k_idx = 0; k_idx < kvlist->count; k_idx++) {
pair = &kvlist->pairs[k_idx];
for (k_idx = 0; k_idx < kvlist->count; k_idx++) {
pair = &kvlist->pairs[k_idx];
@@
-609,6
+633,8
@@
rte_pmd_init_internals(const char *name,
goto error_early;
}
(*internals)->if_name = strdup(pair->value);
goto error_early;
}
(*internals)->if_name = strdup(pair->value);
+ if ((*internals)->if_name == NULL)
+ goto error_early;
(*internals)->if_index = ifr.ifr_ifindex;
if (ioctl(sockfd, SIOCGIFHWADDR, &ifr) == -1) {
(*internals)->if_index = ifr.ifr_ifindex;
if (ioctl(sockfd, SIOCGIFHWADDR, &ifr) == -1) {
@@
-754,7
+780,7
@@
rte_pmd_init_internals(const char *name,
}
/* reserve an ethdev entry */
}
/* reserve an ethdev entry */
- *eth_dev = rte_eth_
dev_allocate(name
);
+ *eth_dev = rte_eth_
vdev_allocate(dev, 0
);
if (*eth_dev == NULL)
goto error;
if (*eth_dev == NULL)
goto error;
@@
-768,22
+794,16
@@
rte_pmd_init_internals(const char *name,
(*internals)->nb_queues = nb_queues;
(*internals)->nb_queues = nb_queues;
+ rte_memcpy(data, (*eth_dev)->data, sizeof(*data));
data->dev_private = *internals;
data->dev_private = *internals;
- data->port_id = (*eth_dev)->data->port_id;
data->nb_rx_queues = (uint16_t)nb_queues;
data->nb_tx_queues = (uint16_t)nb_queues;
data->dev_link = pmd_link;
data->mac_addrs = &(*internals)->eth_addr;
data->nb_rx_queues = (uint16_t)nb_queues;
data->nb_tx_queues = (uint16_t)nb_queues;
data->dev_link = pmd_link;
data->mac_addrs = &(*internals)->eth_addr;
- strncpy(data->name,
- (*eth_dev)->data->name, strlen((*eth_dev)->data->name));
(*eth_dev)->data = data;
(*eth_dev)->dev_ops = &ops;
(*eth_dev)->data = data;
(*eth_dev)->dev_ops = &ops;
- (*eth_dev)->driver = NULL;
(*eth_dev)->data->dev_flags = RTE_ETH_DEV_DETACHABLE;
(*eth_dev)->data->dev_flags = RTE_ETH_DEV_DETACHABLE;
- (*eth_dev)->data->drv_name = pmd_af_packet_drv.driver.name;
- (*eth_dev)->data->kdrv = RTE_KDRV_NONE;
- (*eth_dev)->data->numa_node = numa_node;
return 0;
return 0;
@@
-808,11
+828,11
@@
error_early:
}
static int
}
static int
-rte_eth_from_packet(
const char *name
,
+rte_eth_from_packet(
struct rte_vdev_device *dev
,
int const *sockfd,
int const *sockfd,
- const unsigned numa_node,
struct rte_kvargs *kvlist)
{
struct rte_kvargs *kvlist)
{
+ const char *name = rte_vdev_device_name(dev);
struct pmd_internals *internals = NULL;
struct rte_eth_dev *eth_dev = NULL;
struct rte_kvargs_pair *pair = NULL;
struct pmd_internals *internals = NULL;
struct rte_eth_dev *eth_dev = NULL;
struct rte_kvargs_pair *pair = NULL;
@@
-895,11
+915,11
@@
rte_eth_from_packet(const char *name,
RTE_LOG(INFO, PMD, "%s:\tframe size %d\n", name, framesize);
RTE_LOG(INFO, PMD, "%s:\tframe count %d\n", name, framecount);
RTE_LOG(INFO, PMD, "%s:\tframe size %d\n", name, framesize);
RTE_LOG(INFO, PMD, "%s:\tframe count %d\n", name, framecount);
- if (rte_pmd_init_internals(
name
, *sockfd, qpairs,
- blocksize, blockcount,
- framesize, framecount,
-
numa_node,
&internals, ð_dev,
- kvlist) < 0)
+ if (rte_pmd_init_internals(
dev
, *sockfd, qpairs,
+ blocksize, blockcount,
+ framesize, framecount,
+ &internals, ð_dev,
+ kvlist) < 0)
return -1;
eth_dev->rx_pkt_burst = eth_af_packet_rx;
return -1;
eth_dev->rx_pkt_burst = eth_af_packet_rx;
@@
-909,18
+929,16
@@
rte_eth_from_packet(const char *name,
}
static int
}
static int
-rte_pmd_af_packet_probe(
const char *name, const char *params
)
+rte_pmd_af_packet_probe(
struct rte_vdev_device *dev
)
{
{
- unsigned numa_node;
int ret = 0;
struct rte_kvargs *kvlist;
int sockfd = -1;
int ret = 0;
struct rte_kvargs *kvlist;
int sockfd = -1;
- RTE_LOG(INFO, PMD, "Initializing pmd_af_packet for %s\n", name);
-
- numa_node = rte_socket_id();
+ RTE_LOG(INFO, PMD, "Initializing pmd_af_packet for %s\n",
+ rte_vdev_device_name(dev));
- kvlist = rte_kvargs_parse(
params
, valid_arguments);
+ kvlist = rte_kvargs_parse(
rte_vdev_device_args(dev)
, valid_arguments);
if (kvlist == NULL) {
ret = -1;
goto exit;
if (kvlist == NULL) {
ret = -1;
goto exit;
@@
-938,7
+956,10
@@
rte_pmd_af_packet_probe(const char *name, const char *params)
goto exit;
}
goto exit;
}
- ret = rte_eth_from_packet(name, &sockfd, numa_node, kvlist);
+ if (dev->device.numa_node == SOCKET_ID_ANY)
+ dev->device.numa_node = rte_socket_id();
+
+ ret = rte_eth_from_packet(dev, &sockfd, kvlist);
close(sockfd); /* no longer needed */
exit:
close(sockfd); /* no longer needed */
exit:
@@
-947,7
+968,7
@@
exit:
}
static int
}
static int
-rte_pmd_af_packet_remove(
const char *name
)
+rte_pmd_af_packet_remove(
struct rte_vdev_device *dev
)
{
struct rte_eth_dev *eth_dev = NULL;
struct pmd_internals *internals;
{
struct rte_eth_dev *eth_dev = NULL;
struct pmd_internals *internals;
@@
-956,11
+977,11
@@
rte_pmd_af_packet_remove(const char *name)
RTE_LOG(INFO, PMD, "Closing AF_PACKET ethdev on numa socket %u\n",
rte_socket_id());
RTE_LOG(INFO, PMD, "Closing AF_PACKET ethdev on numa socket %u\n",
rte_socket_id());
- if (
name
== NULL)
+ if (
dev
== NULL)
return -1;
/* find the ethdev entry */
return -1;
/* find the ethdev entry */
- eth_dev = rte_eth_dev_allocated(
name
);
+ eth_dev = rte_eth_dev_allocated(
rte_vdev_device_name(dev)
);
if (eth_dev == NULL)
return -1;
if (eth_dev == NULL)
return -1;