X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Ftap%2Frte_eth_tap.c;h=71be763d66e8b4bc4d7a831766a2d67cba7357ba;hb=6d13ea8e8e49ab957deae2bba5ecf4a4bfe747d1;hp=7f74b5dc986f27b3b4d57a6782e552321fe1e234;hpb=7dccd4e02bcf6eff6480e6ddc8d066b38b3ffc89;p=dpdk.git diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c index 7f74b5dc98..71be763d66 100644 --- a/drivers/net/tap/rte_eth_tap.c +++ b/drivers/net/tap/rte_eth_tap.c @@ -261,7 +261,7 @@ tap_verify_csum(struct rte_mbuf *mbuf) uint32_t l2 = mbuf->packet_type & RTE_PTYPE_L2_MASK; uint32_t l3 = mbuf->packet_type & RTE_PTYPE_L3_MASK; uint32_t l4 = mbuf->packet_type & RTE_PTYPE_L4_MASK; - unsigned int l2_len = sizeof(struct ether_hdr); + unsigned int l2_len = sizeof(struct rte_ether_hdr); unsigned int l3_len; uint16_t cksum = 0; void *l3_hdr; @@ -1150,7 +1150,7 @@ tap_allmulti_disable(struct rte_eth_dev *dev) } static int -tap_mac_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr) +tap_mac_set(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr) { struct pmd_internals *pmd = dev->data->dev_private; enum ioctl_mode mode = LOCAL_ONLY; @@ -1172,15 +1172,16 @@ tap_mac_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr) ret = tap_ioctl(pmd, SIOCGIFHWADDR, &ifr, 0, LOCAL_ONLY); if (ret < 0) return ret; - if (is_same_ether_addr((struct ether_addr *)&ifr.ifr_hwaddr.sa_data, + if (is_same_ether_addr((struct rte_ether_addr *)&ifr.ifr_hwaddr.sa_data, mac_addr)) return 0; /* Check the current MAC address on the remote */ ret = tap_ioctl(pmd, SIOCGIFHWADDR, &ifr, 0, REMOTE_ONLY); if (ret < 0) return ret; - if (!is_same_ether_addr((struct ether_addr *)&ifr.ifr_hwaddr.sa_data, - mac_addr)) + if (!is_same_ether_addr( + (struct rte_ether_addr *)&ifr.ifr_hwaddr.sa_data, + mac_addr)) mode = LOCAL_AND_REMOTE; ifr.ifr_hwaddr.sa_family = AF_LOCAL; rte_memcpy(ifr.ifr_hwaddr.sa_data, mac_addr, ETHER_ADDR_LEN); @@ -1458,7 +1459,7 @@ tap_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) static int tap_set_mc_addr_list(struct rte_eth_dev *dev __rte_unused, - struct ether_addr *mc_addr_set __rte_unused, + struct rte_ether_addr *mc_addr_set __rte_unused, uint32_t nb_mc_addr __rte_unused) { /* @@ -1682,7 +1683,7 @@ static const char *tuntap_types[ETH_TUNTAP_TYPE_MAX] = { static int eth_dev_tap_create(struct rte_vdev_device *vdev, const char *tap_name, - char *remote_iface, struct ether_addr *mac_addr, + char *remote_iface, struct rte_ether_addr *mac_addr, enum rte_tuntap_type type) { int numa_node = rte_socket_id(); @@ -1957,7 +1958,7 @@ set_remote_iface(const char *key __rte_unused, return 0; } -static int parse_user_mac(struct ether_addr *user_mac, +static int parse_user_mac(struct rte_ether_addr *user_mac, const char *value) { unsigned int index = 0; @@ -1985,7 +1986,7 @@ set_mac_type(const char *key __rte_unused, const char *value, void *extra_args) { - struct ether_addr *user_mac = extra_args; + struct rte_ether_addr *user_mac = extra_args; if (!value) return 0; @@ -2111,6 +2112,11 @@ tap_mp_attach_queues(const char *port_name, struct rte_eth_dev *dev) TAP_LOG(DEBUG, "Received IPC reply for %s", reply_param->port_name); /* Attach the queues from received file descriptors */ + if (reply_param->rxq_count + reply_param->txq_count != reply->num_fds) { + TAP_LOG(ERR, "Unexpected number of fds received"); + return -1; + } + dev->data->nb_rx_queues = reply_param->rxq_count; dev->data->nb_tx_queues = reply_param->txq_count; fd_iterator = 0; @@ -2118,7 +2124,7 @@ tap_mp_attach_queues(const char *port_name, struct rte_eth_dev *dev) process_private->rxq_fds[queue] = reply->fds[fd_iterator++]; for (queue = 0; queue < reply_param->txq_count; queue++) process_private->txq_fds[queue] = reply->fds[fd_iterator++]; - + free(reply); return 0; } @@ -2151,19 +2157,24 @@ tap_mp_sync_queues(const struct rte_mp_msg *request, const void *peer) /* Fill file descriptors for all queues */ reply.num_fds = 0; reply_param->rxq_count = 0; + if (dev->data->nb_rx_queues + dev->data->nb_tx_queues > + RTE_MP_MAX_FD_NUM){ + TAP_LOG(ERR, "Number of rx/tx queues exceeds max number of fds"); + return -1; + } + for (queue = 0; queue < dev->data->nb_rx_queues; queue++) { reply.fds[reply.num_fds++] = process_private->rxq_fds[queue]; reply_param->rxq_count++; } RTE_ASSERT(reply_param->rxq_count == dev->data->nb_rx_queues); - RTE_ASSERT(reply_param->txq_count == dev->data->nb_tx_queues); - RTE_ASSERT(reply.num_fds <= RTE_MP_MAX_FD_NUM); reply_param->txq_count = 0; for (queue = 0; queue < dev->data->nb_tx_queues; queue++) { reply.fds[reply.num_fds++] = process_private->txq_fds[queue]; reply_param->txq_count++; } + RTE_ASSERT(reply_param->txq_count == dev->data->nb_tx_queues); /* Send reply */ strlcpy(reply.name, request->name, sizeof(reply.name)); @@ -2188,7 +2199,7 @@ rte_pmd_tap_probe(struct rte_vdev_device *dev) int speed; char tap_name[RTE_ETH_NAME_MAX_LEN]; char remote_iface[RTE_ETH_NAME_MAX_LEN]; - struct ether_addr user_mac = { .addr_bytes = {0} }; + struct rte_ether_addr user_mac = { .addr_bytes = {0} }; struct rte_eth_dev *eth_dev; int tap_devices_count_increased = 0;