Skip to content

Commit

Permalink
netdev: Rename netdev_rx to netdev_rxq
Browse files Browse the repository at this point in the history
Preparation for multi queue netdev IO.  There are no functional changes
in this patch.

Signed-off-by: Pravin B Shelar <[email protected]>
Acked-by: Thomas Graf <[email protected]>
  • Loading branch information
Pravin committed Mar 21, 2014
1 parent e4cfed3 commit f779174
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 144 deletions.
34 changes: 17 additions & 17 deletions lib/dpif-netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ struct dp_netdev_port {
odp_port_t port_no;
struct netdev *netdev;
struct netdev_saved_flags *sf;
struct netdev_rx *rx;
struct netdev_rxq *rxq;
struct ovs_refcount ref_cnt;
char *type; /* Port type as requested by user. */
};
Expand Down Expand Up @@ -697,7 +697,7 @@ do_add_port(struct dp_netdev *dp, const char *devname, const char *type,
port->port_no = port_no;
port->netdev = netdev;
port->type = xstrdup(type);
error = netdev_rx_open(netdev, &port->rx);
error = netdev_rxq_open(netdev, &port->rxq);
if (error
&& !(error == EOPNOTSUPP && dpif_netdev_class_is_dummy(dp->class))) {
VLOG_ERR("%s: cannot receive packets on this network device (%s)",
Expand All @@ -708,9 +708,9 @@ do_add_port(struct dp_netdev *dp, const char *devname, const char *type,

error = netdev_turn_flags_on(netdev, NETDEV_PROMISC, &sf);
if (error) {
netdev_rx_close(port->rx);
netdev_rxq_close(port->rxq);
netdev_close(netdev);
free(port->rx);
free(port->rxq);
free(port);
return error;
}
Expand Down Expand Up @@ -819,7 +819,7 @@ port_unref(struct dp_netdev_port *port)
if (port && ovs_refcount_unref(&port->ref_cnt) == 1) {
netdev_close(port->netdev);
netdev_restore_flags(port->sf);
netdev_rx_close(port->rx);
netdev_rxq_close(port->rxq);
free(port->type);
free(port);
}
Expand Down Expand Up @@ -1723,14 +1723,14 @@ dp_netdev_actions_free(struct dp_netdev_actions *actions)


inline static void
dp_netdev_process_rx_port(struct dp_netdev *dp,
dp_netdev_process_rxq_port(struct dp_netdev *dp,
struct dp_netdev_port *port,
struct netdev_rx *queue)
struct netdev_rxq *rxq)
{
struct ofpbuf *packet[NETDEV_MAX_RX_BATCH];
int error, c;

error = netdev_rx_recv(queue, packet, &c);
error = netdev_rxq_recv(rxq, packet, &c);
if (!error) {
struct pkt_metadata md = PKT_METADATA_INITIALIZER(port->port_no);
int i;
Expand All @@ -1757,8 +1757,8 @@ dpif_netdev_run(struct dpif *dpif)
ovs_rwlock_rdlock(&dp->port_rwlock);

HMAP_FOR_EACH (port, node, &dp->ports) {
if (port->rx && !netdev_is_pmd(port->netdev)) {
dp_netdev_process_rx_port(dp, port, port->rx);
if (port->rxq && !netdev_is_pmd(port->netdev)) {
dp_netdev_process_rxq_port(dp, port, port->rxq);
}
}

Expand All @@ -1774,23 +1774,23 @@ dpif_netdev_wait(struct dpif *dpif)
ovs_rwlock_rdlock(&dp->port_rwlock);

HMAP_FOR_EACH (port, node, &dp->ports) {
if (port->rx && !netdev_is_pmd(port->netdev)) {
netdev_rx_wait(port->rx);
if (port->rxq && !netdev_is_pmd(port->netdev)) {
netdev_rxq_wait(port->rxq);
}
}
ovs_rwlock_unlock(&dp->port_rwlock);
}

struct rx_poll {
struct rxq_poll {
struct dp_netdev_port *port;
};

static int
pmd_load_queues(struct pmd_thread *f,
struct rx_poll **ppoll_list, int poll_cnt)
struct rxq_poll **ppoll_list, int poll_cnt)
{
struct dp_netdev *dp = f->dp;
struct rx_poll *poll_list = *ppoll_list;
struct rxq_poll *poll_list = *ppoll_list;
struct dp_netdev_port *port;
int id = f->id;
int index;
Expand Down Expand Up @@ -1828,7 +1828,7 @@ pmd_thread_main(void *f_)
struct pmd_thread *f = f_;
struct dp_netdev *dp = f->dp;
unsigned int lc = 0;
struct rx_poll *poll_list;
struct rxq_poll *poll_list;
unsigned int port_seq;
int poll_cnt;
int i;
Expand All @@ -1847,7 +1847,7 @@ pmd_thread_main(void *f_)
int i;

for (i = 0; i < poll_cnt; i++) {
dp_netdev_process_rx_port(dp, poll_list[i].port, poll_list[i].port->rx);
dp_netdev_process_rxq_port(dp, poll_list[i].port, poll_list[i].port->rxq);
}

if (lc++ > 1024) {
Expand Down
84 changes: 42 additions & 42 deletions lib/netdev-dummy.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,16 @@ struct netdev_dummy {

struct dummy_packet_conn conn OVS_GUARDED;

FILE *tx_pcap, *rx_pcap OVS_GUARDED;
FILE *tx_pcap, *rxq_pcap OVS_GUARDED;

struct list rxes OVS_GUARDED; /* List of child "netdev_rx_dummy"s. */
struct list rxes OVS_GUARDED; /* List of child "netdev_rxq_dummy"s. */
};

/* Max 'recv_queue_len' in struct netdev_dummy. */
#define NETDEV_DUMMY_MAX_QUEUE 100

struct netdev_rx_dummy {
struct netdev_rx up;
struct netdev_rxq_dummy {
struct netdev_rxq up;
struct list node; /* In netdev_dummy's "rxes" list. */
struct list recv_queue;
int recv_queue_len; /* list_size(&recv_queue). */
Expand All @@ -136,11 +136,11 @@ netdev_dummy_cast(const struct netdev *netdev)
return CONTAINER_OF(netdev, struct netdev_dummy, up);
}

static struct netdev_rx_dummy *
netdev_rx_dummy_cast(const struct netdev_rx *rx)
static struct netdev_rxq_dummy *
netdev_rxq_dummy_cast(const struct netdev_rxq *rx)
{
ovs_assert(is_dummy_class(netdev_get_class(rx->netdev)));
return CONTAINER_OF(rx, struct netdev_rx_dummy, up);
return CONTAINER_OF(rx, struct netdev_rxq_dummy, up);
}

static void
Expand Down Expand Up @@ -684,22 +684,22 @@ netdev_dummy_set_config(struct netdev *netdev_, const struct smap *args)

dummy_packet_conn_set_config(&netdev->conn, args);

if (netdev->rx_pcap) {
fclose(netdev->rx_pcap);
if (netdev->rxq_pcap) {
fclose(netdev->rxq_pcap);
}
if (netdev->tx_pcap && netdev->tx_pcap != netdev->rx_pcap) {
if (netdev->tx_pcap && netdev->tx_pcap != netdev->rxq_pcap) {
fclose(netdev->tx_pcap);
}
netdev->rx_pcap = netdev->tx_pcap = NULL;
netdev->rxq_pcap = netdev->tx_pcap = NULL;
pcap = smap_get(args, "pcap");
if (pcap) {
netdev->rx_pcap = netdev->tx_pcap = ovs_pcap_open(pcap, "ab");
netdev->rxq_pcap = netdev->tx_pcap = ovs_pcap_open(pcap, "ab");
} else {
const char *rx_pcap = smap_get(args, "rx_pcap");
const char *rxq_pcap = smap_get(args, "rxq_pcap");
const char *tx_pcap = smap_get(args, "tx_pcap");

if (rx_pcap) {
netdev->rx_pcap = ovs_pcap_open(rx_pcap, "ab");
if (rxq_pcap) {
netdev->rxq_pcap = ovs_pcap_open(rxq_pcap, "ab");
}
if (tx_pcap) {
netdev->tx_pcap = ovs_pcap_open(tx_pcap, "ab");
Expand All @@ -711,17 +711,17 @@ netdev_dummy_set_config(struct netdev *netdev_, const struct smap *args)
return 0;
}

static struct netdev_rx *
netdev_dummy_rx_alloc(void)
static struct netdev_rxq *
netdev_dummy_rxq_alloc(void)
{
struct netdev_rx_dummy *rx = xzalloc(sizeof *rx);
struct netdev_rxq_dummy *rx = xzalloc(sizeof *rx);
return &rx->up;
}

static int
netdev_dummy_rx_construct(struct netdev_rx *rx_)
netdev_dummy_rxq_construct(struct netdev_rxq *rxq_)
{
struct netdev_rx_dummy *rx = netdev_rx_dummy_cast(rx_);
struct netdev_rxq_dummy *rx = netdev_rxq_dummy_cast(rxq_);
struct netdev_dummy *netdev = netdev_dummy_cast(rx->up.netdev);

ovs_mutex_lock(&netdev->mutex);
Expand All @@ -735,9 +735,9 @@ netdev_dummy_rx_construct(struct netdev_rx *rx_)
}

static void
netdev_dummy_rx_destruct(struct netdev_rx *rx_)
netdev_dummy_rxq_destruct(struct netdev_rxq *rxq_)
{
struct netdev_rx_dummy *rx = netdev_rx_dummy_cast(rx_);
struct netdev_rxq_dummy *rx = netdev_rxq_dummy_cast(rxq_);
struct netdev_dummy *netdev = netdev_dummy_cast(rx->up.netdev);

ovs_mutex_lock(&netdev->mutex);
Expand All @@ -748,17 +748,17 @@ netdev_dummy_rx_destruct(struct netdev_rx *rx_)
}

static void
netdev_dummy_rx_dealloc(struct netdev_rx *rx_)
netdev_dummy_rxq_dealloc(struct netdev_rxq *rxq_)
{
struct netdev_rx_dummy *rx = netdev_rx_dummy_cast(rx_);
struct netdev_rxq_dummy *rx = netdev_rxq_dummy_cast(rxq_);

free(rx);
}

static int
netdev_dummy_rx_recv(struct netdev_rx *rx_, struct ofpbuf **arr, int *c)
netdev_dummy_rxq_recv(struct netdev_rxq *rxq_, struct ofpbuf **arr, int *c)
{
struct netdev_rx_dummy *rx = netdev_rx_dummy_cast(rx_);
struct netdev_rxq_dummy *rx = netdev_rxq_dummy_cast(rxq_);
struct netdev_dummy *netdev = netdev_dummy_cast(rx->up.netdev);
struct ofpbuf *packet;

Expand Down Expand Up @@ -786,9 +786,9 @@ netdev_dummy_rx_recv(struct netdev_rx *rx_, struct ofpbuf **arr, int *c)
}

static void
netdev_dummy_rx_wait(struct netdev_rx *rx_)
netdev_dummy_rxq_wait(struct netdev_rxq *rxq_)
{
struct netdev_rx_dummy *rx = netdev_rx_dummy_cast(rx_);
struct netdev_rxq_dummy *rx = netdev_rxq_dummy_cast(rxq_);
struct netdev_dummy *netdev = netdev_dummy_cast(rx->up.netdev);
uint64_t seq = seq_read(rx->seq);

Expand All @@ -802,9 +802,9 @@ netdev_dummy_rx_wait(struct netdev_rx *rx_)
}

static int
netdev_dummy_rx_drain(struct netdev_rx *rx_)
netdev_dummy_rxq_drain(struct netdev_rxq *rxq_)
{
struct netdev_rx_dummy *rx = netdev_rx_dummy_cast(rx_);
struct netdev_rxq_dummy *rx = netdev_rxq_dummy_cast(rxq_);
struct netdev_dummy *netdev = netdev_dummy_cast(rx->up.netdev);

ovs_mutex_lock(&netdev->mutex);
Expand Down Expand Up @@ -1046,13 +1046,13 @@ static const struct netdev_class dummy_class = {

netdev_dummy_update_flags,

netdev_dummy_rx_alloc,
netdev_dummy_rx_construct,
netdev_dummy_rx_destruct,
netdev_dummy_rx_dealloc,
netdev_dummy_rx_recv,
netdev_dummy_rx_wait,
netdev_dummy_rx_drain,
netdev_dummy_rxq_alloc,
netdev_dummy_rxq_construct,
netdev_dummy_rxq_destruct,
netdev_dummy_rxq_dealloc,
netdev_dummy_rxq_recv,
netdev_dummy_rxq_wait,
netdev_dummy_rxq_drain,
};

static struct ofpbuf *
Expand Down Expand Up @@ -1096,7 +1096,7 @@ eth_from_packet_or_flow(const char *s)
}

static void
netdev_dummy_queue_packet__(struct netdev_rx_dummy *rx, struct ofpbuf *packet)
netdev_dummy_queue_packet__(struct netdev_rxq_dummy *rx, struct ofpbuf *packet)
{
list_push_back(&rx->recv_queue, &packet->list_node);
rx->recv_queue_len++;
Expand All @@ -1107,11 +1107,11 @@ static void
netdev_dummy_queue_packet(struct netdev_dummy *dummy, struct ofpbuf *packet)
OVS_REQUIRES(dummy->mutex)
{
struct netdev_rx_dummy *rx, *prev;
struct netdev_rxq_dummy *rx, *prev;

if (dummy->rx_pcap) {
ovs_pcap_write(dummy->rx_pcap, packet);
fflush(dummy->rx_pcap);
if (dummy->rxq_pcap) {
ovs_pcap_write(dummy->rxq_pcap, packet);
fflush(dummy->rxq_pcap);
}
prev = NULL;
LIST_FOR_EACH (rx, node, &dummy->rxes) {
Expand Down
Loading

0 comments on commit f779174

Please sign in to comment.