Skip to content

Commit 89c09c1

Browse files
blpistokes
authored andcommitted
netdev: Clean up class initialization.
The macros are hard to read. This makes it a little more readable. Signed-off-by: Ben Pfaff <[email protected]> Signed-off-by: Ian Stokes <[email protected]>
1 parent 74cd69a commit 89c09c1

8 files changed

+372
-584
lines changed

configure.ac

+1
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ OVS_ENABLE_OPTION([-Wshadow])
175175
OVS_ENABLE_OPTION([-Wmultistatement-macros])
176176
OVS_ENABLE_OPTION([-Wcast-align=strict])
177177
OVS_ENABLE_OPTION([-Wno-null-pointer-arithmetic])
178+
OVS_ENABLE_OPTION([-Warray-bounds-pointer-arithmetic])
178179
OVS_CONDITIONAL_CC_OPTION([-Wno-unused], [HAVE_WNO_UNUSED])
179180
OVS_CONDITIONAL_CC_OPTION([-Wno-unused-parameter], [HAVE_WNO_UNUSED_PARAMETER])
180181
OVS_ENABLE_WERROR

lib/netdev-dpdk.c

+79-155
Original file line numberDiff line numberDiff line change
@@ -4696,161 +4696,85 @@ netdev_dpdk_flow_del(struct netdev *netdev, const ovs_u128 *ufid,
46964696
ufid, rte_flow);
46974697
}
46984698

4699-
#define DPDK_FLOW_OFFLOAD_API \
4700-
NULL, /* flow_flush */ \
4701-
NULL, /* flow_dump_create */ \
4702-
NULL, /* flow_dump_destroy */ \
4703-
NULL, /* flow_dump_next */ \
4704-
netdev_dpdk_flow_put, \
4705-
NULL, /* flow_get */ \
4706-
netdev_dpdk_flow_del, \
4707-
NULL /* init_flow_api */
4708-
4709-
4710-
#define NETDEV_DPDK_CLASS(NAME, INIT, CONSTRUCT, DESTRUCT, \
4711-
SET_CONFIG, SET_TX_MULTIQ, SEND, \
4712-
GET_CARRIER, GET_STATS, \
4713-
GET_CUSTOM_STATS, \
4714-
GET_FEATURES, GET_STATUS, \
4715-
RECONFIGURE, RXQ_RECV) \
4716-
{ \
4717-
NAME, \
4718-
true, /* is_pmd */ \
4719-
INIT, /* init */ \
4720-
NULL, /* netdev_dpdk_run */ \
4721-
NULL, /* netdev_dpdk_wait */ \
4722-
\
4723-
netdev_dpdk_alloc, \
4724-
CONSTRUCT, \
4725-
DESTRUCT, \
4726-
netdev_dpdk_dealloc, \
4727-
netdev_dpdk_get_config, \
4728-
SET_CONFIG, \
4729-
NULL, /* get_tunnel_config */ \
4730-
NULL, /* build header */ \
4731-
NULL, /* push header */ \
4732-
NULL, /* pop header */ \
4733-
netdev_dpdk_get_numa_id, /* get_numa_id */ \
4734-
SET_TX_MULTIQ, \
4735-
\
4736-
SEND, /* send */ \
4737-
NULL, /* send_wait */ \
4738-
\
4739-
netdev_dpdk_set_etheraddr, \
4740-
netdev_dpdk_get_etheraddr, \
4741-
netdev_dpdk_get_mtu, \
4742-
netdev_dpdk_set_mtu, \
4743-
netdev_dpdk_get_ifindex, \
4744-
GET_CARRIER, \
4745-
netdev_dpdk_get_carrier_resets, \
4746-
netdev_dpdk_set_miimon, \
4747-
GET_STATS, \
4748-
GET_CUSTOM_STATS, \
4749-
GET_FEATURES, \
4750-
NULL, /* set_advertisements */ \
4751-
NULL, /* get_pt_mode */ \
4752-
\
4753-
netdev_dpdk_set_policing, \
4754-
netdev_dpdk_get_qos_types, \
4755-
NULL, /* get_qos_capabilities */ \
4756-
netdev_dpdk_get_qos, \
4757-
netdev_dpdk_set_qos, \
4758-
NULL, /* get_queue */ \
4759-
NULL, /* set_queue */ \
4760-
NULL, /* delete_queue */ \
4761-
NULL, /* get_queue_stats */ \
4762-
NULL, /* queue_dump_start */ \
4763-
NULL, /* queue_dump_next */ \
4764-
NULL, /* queue_dump_done */ \
4765-
NULL, /* dump_queue_stats */ \
4766-
\
4767-
NULL, /* set_in4 */ \
4768-
NULL, /* get_addr_list */ \
4769-
NULL, /* add_router */ \
4770-
NULL, /* get_next_hop */ \
4771-
GET_STATUS, \
4772-
NULL, /* arp_lookup */ \
4773-
\
4774-
netdev_dpdk_update_flags, \
4775-
RECONFIGURE, \
4776-
\
4777-
netdev_dpdk_rxq_alloc, \
4778-
netdev_dpdk_rxq_construct, \
4779-
netdev_dpdk_rxq_destruct, \
4780-
netdev_dpdk_rxq_dealloc, \
4781-
RXQ_RECV, \
4782-
NULL, /* rx_wait */ \
4783-
NULL, /* rxq_drain */ \
4784-
DPDK_FLOW_OFFLOAD_API, \
4785-
NULL /* get_block_id */ \
4786-
}
4787-
4788-
static const struct netdev_class dpdk_class =
4789-
NETDEV_DPDK_CLASS(
4790-
"dpdk",
4791-
netdev_dpdk_class_init,
4792-
netdev_dpdk_construct,
4793-
netdev_dpdk_destruct,
4794-
netdev_dpdk_set_config,
4795-
netdev_dpdk_set_tx_multiq,
4796-
netdev_dpdk_eth_send,
4797-
netdev_dpdk_get_carrier,
4798-
netdev_dpdk_get_stats,
4799-
netdev_dpdk_get_custom_stats,
4800-
netdev_dpdk_get_features,
4801-
netdev_dpdk_get_status,
4802-
netdev_dpdk_reconfigure,
4803-
netdev_dpdk_rxq_recv);
4804-
4805-
static const struct netdev_class dpdk_ring_class =
4806-
NETDEV_DPDK_CLASS(
4807-
"dpdkr",
4808-
netdev_dpdk_class_init,
4809-
netdev_dpdk_ring_construct,
4810-
netdev_dpdk_destruct,
4811-
netdev_dpdk_ring_set_config,
4812-
netdev_dpdk_set_tx_multiq,
4813-
netdev_dpdk_ring_send,
4814-
netdev_dpdk_get_carrier,
4815-
netdev_dpdk_get_stats,
4816-
netdev_dpdk_get_custom_stats,
4817-
netdev_dpdk_get_features,
4818-
netdev_dpdk_get_status,
4819-
netdev_dpdk_reconfigure,
4820-
netdev_dpdk_rxq_recv);
4821-
4822-
static const struct netdev_class dpdk_vhost_class =
4823-
NETDEV_DPDK_CLASS(
4824-
"dpdkvhostuser",
4825-
NULL,
4826-
netdev_dpdk_vhost_construct,
4827-
netdev_dpdk_vhost_destruct,
4828-
NULL,
4829-
NULL,
4830-
netdev_dpdk_vhost_send,
4831-
netdev_dpdk_vhost_get_carrier,
4832-
netdev_dpdk_vhost_get_stats,
4833-
NULL,
4834-
NULL,
4835-
netdev_dpdk_vhost_user_get_status,
4836-
netdev_dpdk_vhost_reconfigure,
4837-
netdev_dpdk_vhost_rxq_recv);
4838-
static const struct netdev_class dpdk_vhost_client_class =
4839-
NETDEV_DPDK_CLASS(
4840-
"dpdkvhostuserclient",
4841-
NULL,
4842-
netdev_dpdk_vhost_client_construct,
4843-
netdev_dpdk_vhost_destruct,
4844-
netdev_dpdk_vhost_client_set_config,
4845-
NULL,
4846-
netdev_dpdk_vhost_send,
4847-
netdev_dpdk_vhost_get_carrier,
4848-
netdev_dpdk_vhost_get_stats,
4849-
NULL,
4850-
NULL,
4851-
netdev_dpdk_vhost_user_get_status,
4852-
netdev_dpdk_vhost_client_reconfigure,
4853-
netdev_dpdk_vhost_rxq_recv);
4699+
#define NETDEV_DPDK_CLASS_COMMON \
4700+
.is_pmd = true, \
4701+
.alloc = netdev_dpdk_alloc, \
4702+
.dealloc = netdev_dpdk_dealloc, \
4703+
.get_config = netdev_dpdk_get_config, \
4704+
.get_numa_id = netdev_dpdk_get_numa_id, \
4705+
.set_etheraddr = netdev_dpdk_set_etheraddr, \
4706+
.get_etheraddr = netdev_dpdk_get_etheraddr, \
4707+
.get_mtu = netdev_dpdk_get_mtu, \
4708+
.set_mtu = netdev_dpdk_set_mtu, \
4709+
.get_ifindex = netdev_dpdk_get_ifindex, \
4710+
.get_carrier_resets = netdev_dpdk_get_carrier_resets, \
4711+
.set_miimon_interval = netdev_dpdk_set_miimon, \
4712+
.set_policing = netdev_dpdk_set_policing, \
4713+
.get_qos_types = netdev_dpdk_get_qos_types, \
4714+
.get_qos = netdev_dpdk_get_qos, \
4715+
.set_qos = netdev_dpdk_set_qos, \
4716+
.update_flags = netdev_dpdk_update_flags, \
4717+
.rxq_alloc = netdev_dpdk_rxq_alloc, \
4718+
.rxq_construct = netdev_dpdk_rxq_construct, \
4719+
.rxq_destruct = netdev_dpdk_rxq_destruct, \
4720+
.rxq_dealloc = netdev_dpdk_rxq_dealloc, \
4721+
DPDK_FLOW_OFFLOAD_API
4722+
4723+
#define NETDEV_DPDK_CLASS_BASE \
4724+
NETDEV_DPDK_CLASS_COMMON, \
4725+
.init = netdev_dpdk_class_init, \
4726+
.destruct = netdev_dpdk_destruct, \
4727+
.set_tx_multiq = netdev_dpdk_set_tx_multiq, \
4728+
.get_carrier = netdev_dpdk_get_carrier, \
4729+
.get_stats = netdev_dpdk_get_stats, \
4730+
.get_custom_stats = netdev_dpdk_get_custom_stats, \
4731+
.get_features = netdev_dpdk_get_features, \
4732+
.get_status = netdev_dpdk_get_status, \
4733+
.reconfigure = netdev_dpdk_reconfigure, \
4734+
.rxq_recv = netdev_dpdk_rxq_recv
4735+
4736+
static const struct netdev_class dpdk_class = {
4737+
.type = "dpdk",
4738+
NETDEV_DPDK_CLASS_BASE,
4739+
.construct = netdev_dpdk_construct,
4740+
.set_config = netdev_dpdk_set_config,
4741+
.send = netdev_dpdk_eth_send,
4742+
};
4743+
4744+
static const struct netdev_class dpdk_ring_class = {
4745+
.type = "dpdkr",
4746+
NETDEV_DPDK_CLASS_BASE,
4747+
.construct = netdev_dpdk_ring_construct,
4748+
.set_config = netdev_dpdk_ring_set_config,
4749+
.send = netdev_dpdk_ring_send,
4750+
};
4751+
4752+
static const struct netdev_class dpdk_vhost_class = {
4753+
.type = "dpdkvhostuser",
4754+
NETDEV_DPDK_CLASS_COMMON,
4755+
.construct = netdev_dpdk_vhost_construct,
4756+
.destruct = netdev_dpdk_vhost_destruct,
4757+
.send = netdev_dpdk_vhost_send,
4758+
.get_carrier = netdev_dpdk_vhost_get_carrier,
4759+
.get_stats = netdev_dpdk_vhost_get_stats,
4760+
.get_status = netdev_dpdk_vhost_user_get_status,
4761+
.reconfigure = netdev_dpdk_vhost_reconfigure,
4762+
.rxq_recv = netdev_dpdk_vhost_rxq_recv
4763+
};
4764+
4765+
static const struct netdev_class dpdk_vhost_client_class = {
4766+
.type = "dpdkvhostuserclient",
4767+
NETDEV_DPDK_CLASS_COMMON,
4768+
.construct = netdev_dpdk_vhost_client_construct,
4769+
.destruct = netdev_dpdk_vhost_destruct,
4770+
.set_config = netdev_dpdk_vhost_client_set_config,
4771+
.send = netdev_dpdk_vhost_send,
4772+
.get_carrier = netdev_dpdk_vhost_get_carrier,
4773+
.get_stats = netdev_dpdk_vhost_get_stats,
4774+
.get_status = netdev_dpdk_vhost_user_get_status,
4775+
.reconfigure = netdev_dpdk_vhost_client_reconfigure,
4776+
.rxq_recv = netdev_dpdk_vhost_rxq_recv
4777+
};
48544778

48554779
void
48564780
netdev_dpdk_register(void)

lib/netdev-dpdk.h

+4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ struct dp_packet;
2525

2626
#ifdef DPDK_NETDEV
2727

28+
#define DPDK_FLOW_OFFLOAD_API \
29+
.flow_put = netdev_dpdk_flow_put, \
30+
.flow_del = netdev_dpdk_flow_del
31+
2832
void netdev_dpdk_register(void);
2933
void free_dpdk_buf(struct dp_packet *);
3034

0 commit comments

Comments
 (0)