]> git.droids-corp.org - dpdk.git/commitdiff
ethdev: make dev_ops const
authorStephen Hemminger <stephen@networkplumber.org>
Tue, 7 Apr 2015 21:21:03 +0000 (14:21 -0700)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Mon, 13 Apr 2015 20:50:10 +0000 (22:50 +0200)
The ethernet device ops function table should be made const for
safety and security.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
17 files changed:
app/test/virtual_pmd.c
lib/librte_ether/rte_ethdev.h
lib/librte_pmd_af_packet/rte_eth_af_packet.c
lib/librte_pmd_e1000/em_ethdev.c
lib/librte_pmd_e1000/igb_ethdev.c
lib/librte_pmd_enic/enic_ethdev.c
lib/librte_pmd_fm10k/fm10k_ethdev.c
lib/librte_pmd_i40e/i40e_ethdev.c
lib/librte_pmd_i40e/i40e_ethdev_vf.c
lib/librte_pmd_ixgbe/ixgbe_ethdev.c
lib/librte_pmd_mlx4/mlx4.c
lib/librte_pmd_null/rte_eth_null.c
lib/librte_pmd_pcap/rte_eth_pcap.c
lib/librte_pmd_ring/rte_eth_ring.c
lib/librte_pmd_virtio/virtio_ethdev.c
lib/librte_pmd_vmxnet3/vmxnet3_ethdev.c
lib/librte_pmd_xenvirt/rte_eth_xenvirt.c

index 3ae8c90dfd1821446541bdd8f4b7457e64ba4559..95818928ffbe685fcb519e4ef04d0bfd506116d6 100644 (file)
@@ -242,21 +242,21 @@ virtual_ethdev_promiscuous_mode_disable(struct rte_eth_dev *dev __rte_unused)
 {}
 
 
-static struct eth_dev_ops virtual_ethdev_default_dev_ops = {
-               .dev_configure = virtual_ethdev_configure_success,
-               .dev_start = virtual_ethdev_start_success,
-               .dev_stop = virtual_ethdev_stop,
-               .dev_close = virtual_ethdev_close,
-               .dev_infos_get = virtual_ethdev_info_get,
-               .rx_queue_setup = virtual_ethdev_rx_queue_setup_success,
-               .tx_queue_setup = virtual_ethdev_tx_queue_setup_success,
-               .rx_queue_release = virtual_ethdev_rx_queue_release,
-               .tx_queue_release = virtual_ethdev_tx_queue_release,
-               .link_update = virtual_ethdev_link_update_success,
-               .stats_get = virtual_ethdev_stats_get,
-               .stats_reset = virtual_ethdev_stats_reset,
-               .promiscuous_enable = virtual_ethdev_promiscuous_mode_enable,
-               .promiscuous_disable = virtual_ethdev_promiscuous_mode_disable
+static const struct eth_dev_ops virtual_ethdev_default_dev_ops = {
+       .dev_configure = virtual_ethdev_configure_success,
+       .dev_start = virtual_ethdev_start_success,
+       .dev_stop = virtual_ethdev_stop,
+       .dev_close = virtual_ethdev_close,
+       .dev_infos_get = virtual_ethdev_info_get,
+       .rx_queue_setup = virtual_ethdev_rx_queue_setup_success,
+       .tx_queue_setup = virtual_ethdev_tx_queue_setup_success,
+       .rx_queue_release = virtual_ethdev_rx_queue_release,
+       .tx_queue_release = virtual_ethdev_tx_queue_release,
+       .link_update = virtual_ethdev_link_update_success,
+       .stats_get = virtual_ethdev_stats_get,
+       .stats_reset = virtual_ethdev_stats_reset,
+       .promiscuous_enable = virtual_ethdev_promiscuous_mode_enable,
+       .promiscuous_disable = virtual_ethdev_promiscuous_mode_disable
 };
 
 
index e8df027965b4fb67e22d51617a0fa9a951c84510..46a55ff9990b85d298965ba2caec53178d34fb11 100644 (file)
@@ -1472,7 +1472,7 @@ struct rte_eth_dev {
        eth_tx_burst_t tx_pkt_burst; /**< Pointer to PMD transmit function. */
        struct rte_eth_dev_data *data;  /**< Pointer to device data */
        const struct eth_driver *driver;/**< Driver for this device */
-       struct eth_dev_ops *dev_ops;    /**< Functions exported by PMD */
+       const struct eth_dev_ops *dev_ops; /**< Functions exported by PMD */
        struct rte_pci_device *pci_dev; /**< PCI info. supplied by probing */
        /** User application callbacks for NIC interrupts */
        struct rte_eth_dev_cb_list link_intr_cbs;
index c10da6c4d1f79bdee322464f4b848691c37c660e..f7e9ec91974a46e9683312f4f6e009568c5cc301 100644 (file)
@@ -384,7 +384,7 @@ eth_tx_queue_setup(struct rte_eth_dev *dev,
        return 0;
 }
 
-static struct eth_dev_ops ops = {
+static const struct eth_dev_ops ops = {
        .dev_start = eth_dev_start,
        .dev_stop = eth_dev_stop,
        .dev_close = eth_dev_close,
index 76f45c947a9972e6bf11eeefad75f7834477432b..12ecf5f27d0ec8affd9a3f69810d2389a0e96f41 100644 (file)
@@ -133,7 +133,7 @@ static struct rte_pci_id pci_id_em_map[] = {
 {.device_id = 0},
 };
 
-static struct eth_dev_ops eth_em_ops = {
+static const struct eth_dev_ops eth_em_ops = {
        .dev_configure        = eth_em_configure,
        .dev_start            = eth_em_start,
        .dev_stop             = eth_em_stop,
index b3892a5155f008c67251240bc06ff4c24238696f..1ea2d38966f126834ab95dab1b6b28f1140f48b5 100644 (file)
@@ -235,7 +235,7 @@ static struct rte_pci_id pci_id_igbvf_map[] = {
 {.device_id = 0},
 };
 
-static struct eth_dev_ops eth_igb_ops = {
+static const struct eth_dev_ops eth_igb_ops = {
        .dev_configure        = eth_igb_configure,
        .dev_start            = eth_igb_start,
        .dev_stop             = eth_igb_stop,
@@ -275,7 +275,7 @@ static struct eth_dev_ops eth_igb_ops = {
  * dev_ops for virtual function, bare necessities for basic vf
  * operation have been implemented
  */
-static struct eth_dev_ops igbvf_eth_dev_ops = {
+static const struct eth_dev_ops igbvf_eth_dev_ops = {
        .dev_configure        = igbvf_dev_configure,
        .dev_start            = igbvf_dev_start,
        .dev_stop             = igbvf_dev_stop,
index 3f45f196374b74d83c64e29835de25b2b15b602f..3e53f86601a743eb4145febde87ed1ecb5eb9924 100644 (file)
@@ -507,7 +507,7 @@ static uint16_t enicpmd_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
        return work_done;
 }
 
-static struct eth_dev_ops enicpmd_eth_dev_ops = {
+static const struct eth_dev_ops enicpmd_eth_dev_ops = {
        .dev_configure        = enicpmd_dev_configure,
        .dev_start            = enicpmd_dev_start,
        .dev_stop             = enicpmd_dev_stop,
index 0c7a80c7f828fe832416cbc438cfb9867e126462..1a96cf2dcc73560f80489d290369474479d1f5a3 100644 (file)
@@ -1651,7 +1651,7 @@ fm10k_close_mbx_service(struct fm10k_hw *hw)
        hw->mbx.ops.disconnect(hw, &hw->mbx);
 }
 
-static struct eth_dev_ops fm10k_eth_dev_ops = {
+static const struct eth_dev_ops fm10k_eth_dev_ops = {
        .dev_configure          = fm10k_dev_configure,
        .dev_start              = fm10k_dev_start,
        .dev_stop               = fm10k_dev_stop,
index 6b8f96e70592659043ea86ef783612347b80fad0..dc447642729fbb84c5939605c99bef0a1394f26b 100644 (file)
@@ -218,7 +218,7 @@ static struct rte_pci_id pci_id_i40e_map[] = {
 { .vendor_id = 0, /* sentinel */ },
 };
 
-static struct eth_dev_ops i40e_eth_dev_ops = {
+static const struct eth_dev_ops i40e_eth_dev_ops = {
        .dev_configure                = i40e_dev_configure,
        .dev_start                    = i40e_dev_start,
        .dev_stop                     = i40e_dev_stop,
index c985e4af3828c1bb680e9ae88401e19bcaad80ae..4581c5b108a62dab9be04f574ff69a82cd1d7159 100644 (file)
@@ -148,7 +148,7 @@ static int i40evf_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
 /* Default hash key buffer for RSS */
 static uint32_t rss_key_default[I40E_VFQF_HKEY_MAX_INDEX + 1];
 
-static struct eth_dev_ops i40evf_eth_dev_ops = {
+static const struct eth_dev_ops i40evf_eth_dev_ops = {
        .dev_configure        = i40evf_dev_configure,
        .dev_start            = i40evf_dev_start,
        .dev_stop             = i40evf_dev_stop,
index 5caee225adb16ad2a31cfd0a3293bd274ff79f37..a7ac8663abd8a7046f9e2384066cd5a3fd62c758 100644 (file)
@@ -317,7 +317,7 @@ static struct rte_pci_id pci_id_ixgbevf_map[] = {
 
 };
 
-static struct eth_dev_ops ixgbe_eth_dev_ops = {
+static const struct eth_dev_ops ixgbe_eth_dev_ops = {
        .dev_configure        = ixgbe_dev_configure,
        .dev_start            = ixgbe_dev_start,
        .dev_stop             = ixgbe_dev_stop,
@@ -387,8 +387,7 @@ static struct eth_dev_ops ixgbe_eth_dev_ops = {
  * dev_ops for virtual function, bare necessities for basic vf
  * operation have been implemented
  */
-static struct eth_dev_ops ixgbevf_eth_dev_ops = {
-
+static const struct eth_dev_ops ixgbevf_eth_dev_ops = {
        .dev_configure        = ixgbevf_dev_configure,
        .dev_start            = ixgbevf_dev_start,
        .dev_stop             = ixgbevf_dev_stop,
index 0eca322d5de1b0dd62882e8372e33a470138ebf2..e0960718c53aff304f91143d47cc1cb69ccf5311 100644 (file)
@@ -4162,7 +4162,7 @@ mlx4_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
        return -ret;
 }
 
-static struct eth_dev_ops mlx4_dev_ops = {
+static const struct eth_dev_ops mlx4_dev_ops = {
        .dev_configure = mlx4_dev_configure,
        .dev_start = mlx4_dev_start,
        .dev_stop = mlx4_dev_stop,
index 036faafaeb760a1d1bf36a7a820ebcba0a716f65..58950659a78d84e5f8c9f037713b1b7438e9097a 100644 (file)
@@ -362,18 +362,18 @@ static int
 eth_link_update(struct rte_eth_dev *dev __rte_unused,
                int wait_to_complete __rte_unused) { return 0; }
 
-static struct eth_dev_ops ops = {
-               .dev_start = eth_dev_start,
-               .dev_stop = eth_dev_stop,
-               .dev_configure = eth_dev_configure,
-               .dev_infos_get = eth_dev_info,
-               .rx_queue_setup = eth_rx_queue_setup,
-               .tx_queue_setup = eth_tx_queue_setup,
-               .rx_queue_release = eth_queue_release,
-               .tx_queue_release = eth_queue_release,
-               .link_update = eth_link_update,
-               .stats_get = eth_stats_get,
-               .stats_reset = eth_stats_reset,
+static const struct eth_dev_ops ops = {
+       .dev_start = eth_dev_start,
+       .dev_stop = eth_dev_stop,
+       .dev_configure = eth_dev_configure,
+       .dev_infos_get = eth_dev_info,
+       .rx_queue_setup = eth_rx_queue_setup,
+       .tx_queue_setup = eth_tx_queue_setup,
+       .rx_queue_release = eth_queue_release,
+       .tx_queue_release = eth_queue_release,
+       .link_update = eth_link_update,
+       .stats_get = eth_stats_get,
+       .stats_reset = eth_stats_reset,
 };
 
 static int
index 3a7db98d049ac2a10f91e874a247dff6b67e1de5..e5d227944e448adc257c1f2d55ee14531f87c07e 100644 (file)
@@ -483,19 +483,19 @@ eth_tx_queue_setup(struct rte_eth_dev *dev,
        return 0;
 }
 
-static struct eth_dev_ops ops = {
-               .dev_start = eth_dev_start,
-               .dev_stop =     eth_dev_stop,
-               .dev_close = eth_dev_close,
-               .dev_configure = eth_dev_configure,
-               .dev_infos_get = eth_dev_info,
-               .rx_queue_setup = eth_rx_queue_setup,
-               .tx_queue_setup = eth_tx_queue_setup,
-               .rx_queue_release = eth_queue_release,
-               .tx_queue_release = eth_queue_release,
-               .link_update = eth_link_update,
-               .stats_get = eth_stats_get,
-               .stats_reset = eth_stats_reset,
+static const struct eth_dev_ops ops = {
+       .dev_start = eth_dev_start,
+       .dev_stop =     eth_dev_stop,
+       .dev_close = eth_dev_close,
+       .dev_configure = eth_dev_configure,
+       .dev_infos_get = eth_dev_info,
+       .rx_queue_setup = eth_rx_queue_setup,
+       .tx_queue_setup = eth_tx_queue_setup,
+       .rx_queue_release = eth_queue_release,
+       .tx_queue_release = eth_queue_release,
+       .link_update = eth_link_update,
+       .stats_get = eth_stats_get,
+       .stats_reset = eth_stats_reset,
 };
 
 static struct eth_driver rte_pcap_pmd = {
index 199e15fcbf96d88cf069d683ad9de40561dc85b4..6832f01e2495912dde192c21d2f6e0ba77861e13 100644 (file)
@@ -234,22 +234,22 @@ static int
 eth_link_update(struct rte_eth_dev *dev __rte_unused,
                int wait_to_complete __rte_unused) { return 0; }
 
-static struct eth_dev_ops ops = {
-               .dev_start = eth_dev_start,
-               .dev_stop = eth_dev_stop,
-               .dev_set_link_up = eth_dev_set_link_up,
-               .dev_set_link_down = eth_dev_set_link_down,
-               .dev_configure = eth_dev_configure,
-               .dev_infos_get = eth_dev_info,
-               .rx_queue_setup = eth_rx_queue_setup,
-               .tx_queue_setup = eth_tx_queue_setup,
-               .rx_queue_release = eth_queue_release,
-               .tx_queue_release = eth_queue_release,
-               .link_update = eth_link_update,
-               .stats_get = eth_stats_get,
-               .stats_reset = eth_stats_reset,
-               .mac_addr_remove = eth_mac_addr_remove,
-               .mac_addr_add = eth_mac_addr_add,
+static const struct eth_dev_ops ops = {
+       .dev_start = eth_dev_start,
+       .dev_stop = eth_dev_stop,
+       .dev_set_link_up = eth_dev_set_link_up,
+       .dev_set_link_down = eth_dev_set_link_down,
+       .dev_configure = eth_dev_configure,
+       .dev_infos_get = eth_dev_info,
+       .rx_queue_setup = eth_rx_queue_setup,
+       .tx_queue_setup = eth_tx_queue_setup,
+       .rx_queue_release = eth_queue_release,
+       .tx_queue_release = eth_queue_release,
+       .link_update = eth_link_update,
+       .stats_get = eth_stats_get,
+       .stats_reset = eth_stats_reset,
+       .mac_addr_remove = eth_mac_addr_remove,
+       .mac_addr_add = eth_mac_addr_add,
 };
 
 int
index 7b83d9b9754868b61656470345c3636963a04727..ffa26a0a83635e9ae27e9cb93f634aaf9397010b 100644 (file)
@@ -499,7 +499,7 @@ virtio_dev_allmulticast_disable(struct rte_eth_dev *dev)
 /*
  * dev_ops for virtio, bare necessities for basic operation
  */
-static struct eth_dev_ops virtio_eth_dev_ops = {
+static const struct eth_dev_ops virtio_eth_dev_ops = {
        .dev_configure           = virtio_dev_configure,
        .dev_start               = virtio_dev_start,
        .dev_stop                = virtio_dev_stop,
index 458dce5698e8530a6fd0e9c8a724d43de2025c7c..577e0f92bc273fff6f2b4e6b0b5a6cce9007ecab 100644 (file)
@@ -99,7 +99,7 @@ static struct rte_pci_id pci_id_vmxnet3_map[] = {
 { .vendor_id = 0, /* sentinel */ },
 };
 
-static struct eth_dev_ops vmxnet3_eth_dev_ops = {
+static const struct eth_dev_ops vmxnet3_eth_dev_ops = {
        .dev_configure        = vmxnet3_dev_configure,
        .dev_start            = vmxnet3_dev_start,
        .dev_stop             = vmxnet3_dev_stop,
index edf2a5fa69c4539899f609f458dbf3dd6a84f49c..73e8bce02a3694ebc92ff05dfe82cde243c8d7f1 100644 (file)
@@ -526,19 +526,19 @@ eth_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
 
 
 
-static struct eth_dev_ops ops = {
-               .dev_start = eth_dev_start,
-               .dev_stop = eth_dev_stop,
-               .dev_close = eth_dev_close,
-               .dev_configure = eth_dev_configure,
-               .dev_infos_get = eth_dev_info,
-               .rx_queue_setup = eth_rx_queue_setup,
-               .tx_queue_setup = eth_tx_queue_setup,
-               .rx_queue_release = eth_queue_release,
-               .tx_queue_release = eth_queue_release,
-               .link_update = eth_link_update,
-               .stats_get = eth_stats_get,
-               .stats_reset = eth_stats_reset,
+static const struct eth_dev_ops ops = {
+       .dev_start = eth_dev_start,
+       .dev_stop = eth_dev_stop,
+       .dev_close = eth_dev_close,
+       .dev_configure = eth_dev_configure,
+       .dev_infos_get = eth_dev_info,
+       .rx_queue_setup = eth_rx_queue_setup,
+       .tx_queue_setup = eth_tx_queue_setup,
+       .rx_queue_release = eth_queue_release,
+       .tx_queue_release = eth_queue_release,
+       .link_update = eth_link_update,
+       .stats_get = eth_stats_get,
+       .stats_reset = eth_stats_reset,
 };