static int
sfc_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size)
{
- struct sfc_adapter *sa = dev->data->dev_private;
+ struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev);
efx_nic_fw_info_t enfi;
int ret;
int rc;
{
const struct sfc_adapter_priv *sap = sfc_adapter_priv_by_eth_dev(dev);
struct sfc_adapter_shared *sas = sfc_adapter_shared_by_eth_dev(dev);
- struct sfc_adapter *sa = dev->data->dev_private;
+ struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev);
struct sfc_rss *rss = &sas->rss;
uint64_t txq_offloads_def = 0;
sfc_dev_supported_ptypes_get(struct rte_eth_dev *dev)
{
const struct sfc_adapter_priv *sap = sfc_adapter_priv_by_eth_dev(dev);
- struct sfc_adapter *sa = dev->data->dev_private;
+ struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev);
const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
uint32_t tunnel_encaps = encp->enc_tunnel_encapsulations_supported;
sfc_dev_configure(struct rte_eth_dev *dev)
{
struct rte_eth_dev_data *dev_data = dev->data;
- struct sfc_adapter *sa = dev_data->dev_private;
+ struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev);
int rc;
sfc_log_init(sa, "entry n_rxq=%u n_txq=%u",
static int
sfc_dev_start(struct rte_eth_dev *dev)
{
- struct sfc_adapter *sa = dev->data->dev_private;
+ struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev);
int rc;
sfc_log_init(sa, "entry");
static int
sfc_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete)
{
- struct sfc_adapter *sa = dev->data->dev_private;
+ struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev);
struct rte_eth_link current_link;
int ret;
static void
sfc_dev_stop(struct rte_eth_dev *dev)
{
- struct sfc_adapter *sa = dev->data->dev_private;
+ struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev);
sfc_log_init(sa, "entry");
static int
sfc_dev_set_link_up(struct rte_eth_dev *dev)
{
- struct sfc_adapter *sa = dev->data->dev_private;
+ struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev);
int rc;
sfc_log_init(sa, "entry");
static int
sfc_dev_set_link_down(struct rte_eth_dev *dev)
{
- struct sfc_adapter *sa = dev->data->dev_private;
+ struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev);
sfc_log_init(sa, "entry");
static void
sfc_dev_close(struct rte_eth_dev *dev)
{
- struct sfc_adapter *sa = dev->data->dev_private;
+ struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev);
sfc_log_init(sa, "entry");
{
struct sfc_port *port;
boolean_t *toggle;
- struct sfc_adapter *sa = dev->data->dev_private;
+ struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev);
boolean_t allmulti = (mode == SFC_DEV_FILTER_MODE_ALLMULTI);
const char *desc = (allmulti) ? "all-multi" : "promiscuous";
struct rte_mempool *mb_pool)
{
struct sfc_adapter_shared *sas = sfc_adapter_shared_by_eth_dev(dev);
- struct sfc_adapter *sa = dev->data->dev_private;
+ struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev);
int rc;
sfc_log_init(sa, "RxQ=%u nb_rx_desc=%u socket_id=%u",
const struct rte_eth_txconf *tx_conf)
{
struct sfc_adapter_shared *sas = sfc_adapter_shared_by_eth_dev(dev);
- struct sfc_adapter *sa = dev->data->dev_private;
+ struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev);
int rc;
sfc_log_init(sa, "TxQ = %u, nb_tx_desc = %u, socket_id = %u",
static int
sfc_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
{
- struct sfc_adapter *sa = dev->data->dev_private;
+ struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev);
struct sfc_port *port = &sa->port;
uint64_t *mac_stats;
int ret;
static void
sfc_stats_reset(struct rte_eth_dev *dev)
{
- struct sfc_adapter *sa = dev->data->dev_private;
+ struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev);
struct sfc_port *port = &sa->port;
int rc;
sfc_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
unsigned int xstats_count)
{
- struct sfc_adapter *sa = dev->data->dev_private;
+ struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev);
struct sfc_port *port = &sa->port;
uint64_t *mac_stats;
int rc;
struct rte_eth_xstat_name *xstats_names,
unsigned int xstats_count)
{
- struct sfc_adapter *sa = dev->data->dev_private;
+ struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev);
struct sfc_port *port = &sa->port;
unsigned int i;
unsigned int nstats = 0;
sfc_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids,
uint64_t *values, unsigned int n)
{
- struct sfc_adapter *sa = dev->data->dev_private;
+ struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev);
struct sfc_port *port = &sa->port;
uint64_t *mac_stats;
unsigned int nb_supported = 0;
struct rte_eth_xstat_name *xstats_names,
const uint64_t *ids, unsigned int size)
{
- struct sfc_adapter *sa = dev->data->dev_private;
+ struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev);
struct sfc_port *port = &sa->port;
unsigned int nb_supported = 0;
unsigned int nb_written = 0;
static int
sfc_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
{
- struct sfc_adapter *sa = dev->data->dev_private;
+ struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev);
unsigned int wanted_fc, link_fc;
memset(fc_conf, 0, sizeof(*fc_conf));
static int
sfc_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
{
- struct sfc_adapter *sa = dev->data->dev_private;
+ struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev);
struct sfc_port *port = &sa->port;
unsigned int fcntl;
int rc;
static int
sfc_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
{
- struct sfc_adapter *sa = dev->data->dev_private;
+ struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev);
size_t pdu = EFX_MAC_PDU(mtu);
size_t old_pdu;
int rc;
static int
sfc_mac_addr_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr)
{
- struct sfc_adapter *sa = dev->data->dev_private;
+ struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev);
const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
struct sfc_port *port = &sa->port;
struct ether_addr *old_addr = &dev->data->mac_addrs[0];
sfc_set_mc_addr_list(struct rte_eth_dev *dev, struct ether_addr *mc_addr_set,
uint32_t nb_mc_addr)
{
- struct sfc_adapter *sa = dev->data->dev_private;
+ struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev);
struct sfc_port *port = &sa->port;
uint8_t *mc_addrs = port->mcast_addrs;
int rc;
sfc_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id)
{
struct sfc_adapter_shared *sas = sfc_adapter_shared_by_eth_dev(dev);
- struct sfc_adapter *sa = dev->data->dev_private;
+ struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev);
int rc;
sfc_log_init(sa, "RxQ=%u", rx_queue_id);
sfc_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id)
{
struct sfc_adapter_shared *sas = sfc_adapter_shared_by_eth_dev(dev);
- struct sfc_adapter *sa = dev->data->dev_private;
+ struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev);
sfc_log_init(sa, "RxQ=%u", rx_queue_id);
sfc_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id)
{
struct sfc_adapter_shared *sas = sfc_adapter_shared_by_eth_dev(dev);
- struct sfc_adapter *sa = dev->data->dev_private;
+ struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev);
int rc;
sfc_log_init(sa, "TxQ = %u", tx_queue_id);
sfc_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)
{
struct sfc_adapter_shared *sas = sfc_adapter_shared_by_eth_dev(dev);
- struct sfc_adapter *sa = dev->data->dev_private;
+ struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev);
sfc_log_init(sa, "TxQ = %u", tx_queue_id);
struct rte_eth_udp_tunnel *tunnel_udp,
enum sfc_udp_tunnel_op_e op)
{
- struct sfc_adapter *sa = dev->data->dev_private;
+ struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev);
efx_tunnel_protocol_t tunnel_proto;
int rc;
sfc_dev_rss_hash_update(struct rte_eth_dev *dev,
struct rte_eth_rss_conf *rss_conf)
{
- struct sfc_adapter *sa = dev->data->dev_private;
+ struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev);
struct sfc_rss *rss = &sfc_sa2shared(sa)->rss;
unsigned int efx_hash_types;
int rc = 0;
struct rte_eth_rss_reta_entry64 *reta_conf,
uint16_t reta_size)
{
- struct sfc_adapter *sa = dev->data->dev_private;
+ struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev);
struct sfc_rss *rss = &sfc_sa2shared(sa)->rss;
unsigned int *rss_tbl_new;
uint16_t entry;
enum rte_filter_op filter_op,
void *arg)
{
- struct sfc_adapter *sa = dev->data->dev_private;
+ struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev);
int rc = ENOTSUP;
sfc_log_init(sa, "entry");
static int
sfc_eth_dev_set_ops(struct rte_eth_dev *dev)
{
- struct sfc_adapter *sa = dev->data->dev_private;
+ struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev);
struct sfc_adapter_shared *sas = sfc_adapter_shared_by_eth_dev(dev);
const struct sfc_dp_rx *dp_rx;
const struct sfc_dp_tx *dp_tx;
static void
sfc_eth_dev_clear_ops(struct rte_eth_dev *dev)
{
- struct sfc_adapter *sa = dev->data->dev_private;
+ struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev);
struct sfc_adapter_shared *sas = sfc_adapter_shared_by_eth_dev(dev);
dev->dev_ops = NULL;
static int
sfc_eth_dev_init(struct rte_eth_dev *dev)
{
- struct sfc_adapter *sa = dev->data->dev_private;
- struct sfc_adapter_shared *sas;
+ struct sfc_adapter_shared *sas = sfc_adapter_shared_by_eth_dev(dev);
struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
uint32_t logtype_main;
+ struct sfc_adapter *sa;
int rc;
const efx_nic_cfg_t *encp;
const struct ether_addr *from;
SFC_LOGTYPE_MAIN_STR,
RTE_LOG_NOTICE);
- sa->priv.shared = &sa->_shared;
- sas = sa->priv.shared;
-
if (rte_eal_process_type() != RTE_PROC_PRIMARY)
return -sfc_eth_dev_secondary_init(dev, logtype_main);
+ /* Required for logging */
+ sas->pci_addr = pci_dev->addr;
+ sas->port_id = dev->data->port_id;
+
/*
- * sfc_adapter is a mixture of shared and process private data.
- * During transition period use it in both kinds. When the
- * driver becomes ready to separate it, sfc_adapter will become
- * primary process private only.
+ * Allocate process private data from heap, since it should not
+ * be located in shared memory allocated using rte_malloc() API.
*/
+ sa = calloc(1, sizeof(*sa));
+ if (sa == NULL) {
+ rc = ENOMEM;
+ goto fail_alloc_sa;
+ }
+
dev->process_private = sa;
/* Required for logging */
- sas->pci_addr = pci_dev->addr;
- sas->port_id = dev->data->port_id;
+ sa->priv.shared = sas;
sa->priv.logtype_main = logtype_main;
sa->eth_dev = dev;
fail_kvargs_parse:
sfc_log_init(sa, "failed %d", rc);
dev->process_private = NULL;
+ free(sa);
+
+fail_alloc_sa:
SFC_ASSERT(rc > 0);
return -rc;
}
return 0;
}
- sa = dev->data->dev_private;
+ sa = sfc_adapter_by_eth_dev(dev);
sfc_log_init(sa, "entry");
sfc_adapter_lock(sa);
/* Required for logging, so cleanup last */
sa->eth_dev = NULL;
+
+ dev->process_private = NULL;
+ free(sa);
+
return 0;
}
struct rte_pci_device *pci_dev)
{
return rte_eth_dev_pci_generic_probe(pci_dev,
- sizeof(struct sfc_adapter), sfc_eth_dev_init);
+ sizeof(struct sfc_adapter_shared), sfc_eth_dev_init);
}
static int sfc_eth_dev_pci_remove(struct rte_pci_device *pci_dev)