From: Stephen Hemminger <stephen-OTpzqLSitTUnbdJkjeBofR2eb7JE58TQ@public.gmane.org>
To: Ouyang Changchun
<changchun.ouyang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: dev-VfR2kkLFssw@public.gmane.org
Subject: [RFC 07/10] virtio: remove unnecessary adapter structure
Date: Mon, 25 Aug 2014 19:07:53 -0700 [thread overview]
Message-ID: <20140826020851.474452281@networkplumber.org> (raw)
In-Reply-To: 20140826020746.062748014@networkplumber.org
[-- Attachment #1: virtio-adapter-cleanout.patch --]
[-- Type: text/plain, Size: 5501 bytes --]
Cleanup virtio code by eliminating unnecessary nesting of
virtio hardware structure inside adapter structure.
Also allows removing unneeded macro, making code clearer.
---
lib/librte_pmd_virtio/virtio_ethdev.c | 31 +++++++++++--------------------
lib/librte_pmd_virtio/virtio_ethdev.h | 9 ---------
lib/librte_pmd_virtio/virtio_rxtx.c | 3 +--
3 files changed, 12 insertions(+), 31 deletions(-)
--- a/lib/librte_pmd_virtio/virtio_ethdev.c 2014-08-25 19:00:08.310541279 -0700
+++ b/lib/librte_pmd_virtio/virtio_ethdev.c 2014-08-25 19:00:08.310541279 -0700
@@ -203,8 +203,7 @@ virtio_send_command(struct virtqueue *vq
static int
virtio_set_multiple_queues(struct rte_eth_dev *dev, uint16_t nb_queues)
{
- struct virtio_hw *hw
- = VIRTIO_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ struct virtio_hw *hw = dev->data->dev_private;
struct virtio_pmd_ctrl ctrl;
int dlen[1];
int ret;
@@ -238,8 +237,7 @@ int virtio_dev_queue_setup(struct rte_et
const struct rte_memzone *mz;
uint16_t vq_size;
int size;
- struct virtio_hw *hw =
- VIRTIO_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ struct virtio_hw *hw = dev->data->dev_private;
struct virtqueue *vq = NULL;
/* Write the virtqueue index to the Queue Select Field */
@@ -379,8 +377,7 @@ virtio_dev_cq_queue_setup(struct rte_eth
struct virtqueue *vq;
uint16_t nb_desc = 0;
int ret;
- struct virtio_hw *hw =
- VIRTIO_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ struct virtio_hw *hw = dev->data->dev_private;
PMD_INIT_FUNC_TRACE();
ret = virtio_dev_queue_setup(dev, VTNET_CQ, VTNET_SQ_CQ_QUEUE_IDX,
@@ -765,8 +762,7 @@ virtio_interrupt_handler(__rte_unused st
void *param)
{
struct rte_eth_dev *dev = param;
- struct virtio_hw *hw =
- VIRTIO_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ struct virtio_hw *hw = dev->data->dev_private;
uint8_t isr;
/* Read interrupt status which clears interrupt */
@@ -792,12 +788,11 @@ static int
eth_virtio_dev_init(__rte_unused struct eth_driver *eth_drv,
struct rte_eth_dev *eth_dev)
{
+ struct virtio_hw *hw = eth_dev->data->dev_private;
struct virtio_net_config *config;
struct virtio_net_config local_config;
uint32_t offset_conf = sizeof(config->mac);
struct rte_pci_device *pci_dev;
- struct virtio_hw *hw =
- VIRTIO_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
if (RTE_PKTMBUF_HEADROOM < sizeof(struct virtio_net_hdr)) {
PMD_INIT_LOG(ERR,
@@ -928,7 +923,7 @@ static struct eth_driver rte_virtio_pmd
.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
},
.eth_dev_init = eth_virtio_dev_init,
- .dev_private_size = sizeof(struct virtio_adapter),
+ .dev_private_size = sizeof(struct virtio_hw),
};
/*
@@ -965,8 +960,7 @@ static int
virtio_dev_configure(struct rte_eth_dev *dev)
{
const struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;
- struct virtio_hw *hw =
- VIRTIO_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ struct virtio_hw *hw = dev->data->dev_private;
int ret;
PMD_INIT_LOG(DEBUG, "configure");
@@ -990,8 +984,7 @@ static int
virtio_dev_start(struct rte_eth_dev *dev)
{
uint16_t nb_queues, i;
- struct virtio_hw *hw =
- VIRTIO_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ struct virtio_hw *hw = dev->data->dev_private;
/* Tell the host we've noticed this device. */
vtpci_set_status(hw, VIRTIO_CONFIG_STATUS_ACK);
@@ -1097,8 +1090,7 @@ static void virtio_dev_free_mbufs(struct
static void
virtio_dev_stop(struct rte_eth_dev *dev)
{
- struct virtio_hw *hw =
- VIRTIO_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ struct virtio_hw *hw = dev->data->dev_private;
/* reset the NIC */
vtpci_irq_config(hw, 0);
@@ -1111,8 +1103,7 @@ virtio_dev_link_update(struct rte_eth_de
{
struct rte_eth_link link, old;
uint16_t status;
- struct virtio_hw *hw =
- VIRTIO_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ struct virtio_hw *hw = dev->data->dev_private;
memset(&link, 0, sizeof(link));
virtio_dev_atomic_read_link_status(dev, &link);
old = link;
@@ -1144,7 +1135,7 @@ virtio_dev_link_update(struct rte_eth_de
static void
virtio_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
{
- struct virtio_hw *hw = VIRTIO_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ struct virtio_hw *hw = dev->data->dev_private;
dev_info->driver_name = dev->driver->pci_drv.name;
dev_info->max_rx_queues = (uint16_t)hw->max_rx_queues;
--- a/lib/librte_pmd_virtio/virtio_ethdev.h 2014-08-25 19:00:08.310541279 -0700
+++ b/lib/librte_pmd_virtio/virtio_ethdev.h 2014-08-25 19:00:08.310541279 -0700
@@ -110,15 +110,6 @@ uint16_t virtio_recv_mergeable_pkts(void
uint16_t virtio_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
uint16_t nb_pkts);
-/*
- * Structure to store private data for each driver instance (for each port).
- */
-struct virtio_adapter {
- struct virtio_hw hw;
-};
-
-#define VIRTIO_DEV_PRIVATE_TO_HW(adapter)\
- (&((struct virtio_adapter *)adapter)->hw)
/*
* The VIRTIO_NET_F_GUEST_TSO[46] features permit the host to send us
--- a/lib/librte_pmd_virtio/virtio_rxtx.c 2014-08-25 19:00:08.310541279 -0700
+++ b/lib/librte_pmd_virtio/virtio_rxtx.c 2014-08-25 19:00:08.310541279 -0700
@@ -326,8 +326,7 @@ virtio_dev_vring_start(struct virtqueue
void
virtio_dev_cq_start(struct rte_eth_dev *dev)
{
- struct virtio_hw *hw
- = VIRTIO_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ struct virtio_hw *hw = dev->data->dev_private;
virtio_dev_vring_start(hw->cvq, VTNET_CQ);
VIRTQUEUE_DUMP((struct virtqueue *)hw->cvq);
next prev parent reply other threads:[~2014-08-26 2:07 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-26 2:07 [RFC 00/10] virtio patches Stephen Hemminger
2014-08-26 2:07 ` [RFC 01/10] virtio: rearrange resource initialization Stephen Hemminger
[not found] ` <20140826020837.898427212-OTpzqLSitTUnbdJkjeBofR2eb7JE58TQ@public.gmane.org>
2014-08-26 7:14 ` Ouyang, Changchun
2014-08-26 2:07 ` [RFC 02/10] virtio: use weak barriers Stephen Hemminger
2014-08-26 2:07 ` [RFC 03/10] virtio: allow starting with link down Stephen Hemminger
2014-08-26 2:07 ` [RFC 04/10] virtio: add support for Link State interrupt Stephen Hemminger
2014-08-26 2:07 ` [RFC 05/10] ether: add soft vlan encap/decap functions Stephen Hemminger
2014-08-26 2:07 ` [RFC 06/10] virtio: use software vlan stripping Stephen Hemminger
[not found] ` <20140826020848.386074683-OTpzqLSitTUnbdJkjeBofR2eb7JE58TQ@public.gmane.org>
2014-08-26 8:37 ` Ouyang, Changchun
[not found] ` <F52918179C57134FAEC9EA62FA2F96251183B285-E2R4CRU6q/6iAffOGbnezLfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2014-08-26 16:24 ` Stephen Hemminger
2014-08-27 5:42 ` Ouyang, Changchun
[not found] ` <F52918179C57134FAEC9EA62FA2F96251183B79C-E2R4CRU6q/6iAffOGbnezLfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2014-08-27 18:04 ` Stephen Hemminger
2014-08-26 2:07 ` Stephen Hemminger [this message]
[not found] ` <20140826020851.474452281-OTpzqLSitTUnbdJkjeBofR2eb7JE58TQ@public.gmane.org>
2014-08-26 6:43 ` [RFC 07/10] virtio: remove unnecessary adapter structure Ouyang, Changchun
2014-08-26 2:07 ` [RFC 08/10] virtio: remove redundant vq_alignment Stephen Hemminger
[not found] ` <20140826020853.851222673-OTpzqLSitTUnbdJkjeBofR2eb7JE58TQ@public.gmane.org>
2014-08-26 8:41 ` Ouyang, Changchun
2014-08-26 2:07 ` [RFC 09/10] virtio: fix how states are handled during initialization Stephen Hemminger
2014-08-26 2:07 ` [RFC 10/10] virtio: add support for promiscious and multicast Stephen Hemminger
[not found] ` <20140826020858.448904783-OTpzqLSitTUnbdJkjeBofR2eb7JE58TQ@public.gmane.org>
2014-08-26 6:55 ` Ouyang, Changchun
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=20140826020851.474452281@networkplumber.org \
--to=stephen-otpzqlsittunbdjkjebofr2eb7je58tq@public.gmane.org \
--cc=changchun.ouyang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=dev-VfR2kkLFssw@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.