ethdev: add an argument to internal callback function
add cb_arg parameter to the _rte_eth_dev_callback_process function. Adding a parameter to this function allows passing information to the application when an eth device event occurs such as a VF to PF message. This allows the application to decide if a particular function is permitted. Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com> Signed-off-by: Alex Zelezniak <alexz@att.com>
This commit is contained in:
parent
01f1922786
commit
c1ceaf3ad0
@ -485,7 +485,7 @@ virtual_ethdev_simulate_link_status_interrupt(uint8_t port_id,
|
||||
|
||||
vrtl_eth_dev->data->dev_link.link_status = link_status;
|
||||
|
||||
_rte_eth_dev_callback_process(vrtl_eth_dev, RTE_ETH_EVENT_INTR_LSC);
|
||||
_rte_eth_dev_callback_process(vrtl_eth_dev, RTE_ETH_EVENT_INTR_LSC, NULL);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -1958,7 +1958,7 @@ bond_ethdev_delayed_lsc_propagation(void *arg)
|
||||
return;
|
||||
|
||||
_rte_eth_dev_callback_process((struct rte_eth_dev *)arg,
|
||||
RTE_ETH_EVENT_INTR_LSC);
|
||||
RTE_ETH_EVENT_INTR_LSC, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
@ -2079,7 +2079,7 @@ bond_ethdev_lsc_event_callback(uint8_t port_id, enum rte_eth_event_type type,
|
||||
(void *)bonded_eth_dev);
|
||||
else
|
||||
_rte_eth_dev_callback_process(bonded_eth_dev,
|
||||
RTE_ETH_EVENT_INTR_LSC);
|
||||
RTE_ETH_EVENT_INTR_LSC, NULL);
|
||||
|
||||
} else {
|
||||
if (internals->link_down_delay_ms > 0)
|
||||
@ -2088,7 +2088,7 @@ bond_ethdev_lsc_event_callback(uint8_t port_id, enum rte_eth_event_type type,
|
||||
(void *)bonded_eth_dev);
|
||||
else
|
||||
_rte_eth_dev_callback_process(bonded_eth_dev,
|
||||
RTE_ETH_EVENT_INTR_LSC);
|
||||
RTE_ETH_EVENT_INTR_LSC, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1599,7 +1599,7 @@ eth_em_interrupt_handler(__rte_unused struct rte_intr_handle *handle,
|
||||
|
||||
eth_em_interrupt_get_status(dev);
|
||||
eth_em_interrupt_action(dev);
|
||||
_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC);
|
||||
_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -2683,7 +2683,7 @@ eth_igb_interrupt_action(struct rte_eth_dev *dev)
|
||||
E1000_WRITE_REG(hw, E1000_TCTL, tctl);
|
||||
E1000_WRITE_REG(hw, E1000_RCTL, rctl);
|
||||
E1000_WRITE_FLUSH(hw);
|
||||
_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC);
|
||||
_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -2743,7 +2743,7 @@ void igbvf_mbx_process(struct rte_eth_dev *dev)
|
||||
|
||||
/* PF reset VF event */
|
||||
if (in_msg == E1000_PF_CONTROL_MSG)
|
||||
_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_RESET);
|
||||
_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_RESET, NULL);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -436,7 +436,7 @@ enic_intr_handler(__rte_unused struct rte_intr_handle *handle,
|
||||
vnic_intr_return_all_credits(&enic->intr);
|
||||
|
||||
enic_link_update(enic);
|
||||
_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC);
|
||||
_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL);
|
||||
enic_log_q_error(enic);
|
||||
}
|
||||
|
||||
|
@ -5516,7 +5516,7 @@ i40e_dev_interrupt_delayed_handler(void *param)
|
||||
|
||||
/* handle the link up interrupt in an alarm callback */
|
||||
i40e_dev_link_update(dev, 0);
|
||||
_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC);
|
||||
_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL);
|
||||
|
||||
i40e_pf_enable_irq0(hw);
|
||||
rte_intr_enable(&(dev->pci_dev->intr_handle));
|
||||
@ -5600,7 +5600,7 @@ i40e_dev_interrupt_handler(__rte_unused struct rte_intr_handle *handle,
|
||||
return;
|
||||
else
|
||||
_rte_eth_dev_callback_process(dev,
|
||||
RTE_ETH_EVENT_INTR_LSC);
|
||||
RTE_ETH_EVENT_INTR_LSC, NULL);
|
||||
}
|
||||
|
||||
done:
|
||||
|
@ -1341,7 +1341,7 @@ i40evf_handle_pf_event(__rte_unused struct rte_eth_dev *dev,
|
||||
switch (pf_msg->event) {
|
||||
case I40E_VIRTCHNL_EVENT_RESET_IMPENDING:
|
||||
PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_RESET_IMPENDING event\n");
|
||||
_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_RESET);
|
||||
_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_RESET, NULL);
|
||||
break;
|
||||
case I40E_VIRTCHNL_EVENT_LINK_CHANGE:
|
||||
PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_LINK_CHANGE event\n");
|
||||
|
@ -3559,7 +3559,7 @@ ixgbe_dev_interrupt_delayed_handler(void *param)
|
||||
ixgbe_dev_link_update(dev, 0);
|
||||
intr->flags &= ~IXGBE_FLAG_NEED_LINK_UPDATE;
|
||||
ixgbe_dev_link_status_print(dev);
|
||||
_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC);
|
||||
_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL);
|
||||
}
|
||||
|
||||
PMD_DRV_LOG(DEBUG, "enable intr in delayed handler S[%08x]", eicr);
|
||||
@ -7541,7 +7541,7 @@ static void ixgbevf_mbx_process(struct rte_eth_dev *dev)
|
||||
|
||||
/* PF reset VF event */
|
||||
if (in_msg == IXGBE_PF_CONTROL_MSG)
|
||||
_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_RESET);
|
||||
_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_RESET, NULL);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -5448,7 +5448,7 @@ mlx4_dev_link_status_handler(void *arg)
|
||||
ret = priv_dev_link_status_handler(priv, dev);
|
||||
priv_unlock(priv);
|
||||
if (ret)
|
||||
_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC);
|
||||
_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -5471,7 +5471,7 @@ mlx4_dev_interrupt_handler(struct rte_intr_handle *intr_handle, void *cb_arg)
|
||||
ret = priv_dev_link_status_handler(priv, dev);
|
||||
priv_unlock(priv);
|
||||
if (ret)
|
||||
_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC);
|
||||
_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1069,7 +1069,7 @@ mlx5_dev_link_status_handler(void *arg)
|
||||
ret = priv_dev_link_status_handler(priv, dev);
|
||||
priv_unlock(priv);
|
||||
if (ret)
|
||||
_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC);
|
||||
_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1092,7 +1092,7 @@ mlx5_dev_interrupt_handler(struct rte_intr_handle *intr_handle, void *cb_arg)
|
||||
ret = priv_dev_link_status_handler(priv, dev);
|
||||
priv_unlock(priv);
|
||||
if (ret)
|
||||
_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC);
|
||||
_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1219,7 +1219,7 @@ nfp_net_dev_interrupt_delayed_handler(void *param)
|
||||
struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
|
||||
|
||||
nfp_net_link_update(dev, 0);
|
||||
_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC);
|
||||
_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL);
|
||||
|
||||
nfp_net_dev_link_status_print(dev);
|
||||
|
||||
|
@ -111,7 +111,7 @@ nicvf_interrupt(void *arg)
|
||||
if (nicvf_reg_poll_interrupts(nic) == NIC_MBOX_MSG_BGX_LINK_CHANGE) {
|
||||
if (dev->data->dev_conf.intr_conf.lsc)
|
||||
nicvf_set_eth_link_status(nic, &dev->data->dev_link);
|
||||
_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC);
|
||||
_rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL);
|
||||
}
|
||||
|
||||
rte_eal_alarm_set(NICVF_INTR_POLL_INTERVAL_MS * 1000,
|
||||
|
@ -561,7 +561,7 @@ new_device(int vid)
|
||||
|
||||
RTE_LOG(INFO, PMD, "New connection established\n");
|
||||
|
||||
_rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_INTR_LSC);
|
||||
_rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_INTR_LSC, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -628,7 +628,7 @@ destroy_device(int vid)
|
||||
|
||||
RTE_LOG(INFO, PMD, "Connection closed\n");
|
||||
|
||||
_rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_INTR_LSC);
|
||||
_rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_INTR_LSC, NULL);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -657,7 +657,7 @@ vring_state_changed(int vid, uint16_t vring, int enable)
|
||||
RTE_LOG(INFO, PMD, "vring%u is %s\n",
|
||||
vring, enable ? "enabled" : "disabled");
|
||||
|
||||
_rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_QUEUE_STATE);
|
||||
_rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_QUEUE_STATE, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1126,7 +1126,7 @@ virtio_interrupt_handler(__rte_unused struct rte_intr_handle *handle,
|
||||
if (isr & VIRTIO_PCI_ISR_CONFIG) {
|
||||
if (virtio_dev_link_update(dev, 0) == 0)
|
||||
_rte_eth_dev_callback_process(dev,
|
||||
RTE_ETH_EVENT_INTR_LSC);
|
||||
RTE_ETH_EVENT_INTR_LSC, NULL);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2508,7 +2508,7 @@ rte_eth_dev_callback_unregister(uint8_t port_id,
|
||||
|
||||
void
|
||||
_rte_eth_dev_callback_process(struct rte_eth_dev *dev,
|
||||
enum rte_eth_event_type event)
|
||||
enum rte_eth_event_type event, void *cb_arg)
|
||||
{
|
||||
struct rte_eth_dev_callback *cb_lst;
|
||||
struct rte_eth_dev_callback dev_cb;
|
||||
@ -2519,6 +2519,9 @@ _rte_eth_dev_callback_process(struct rte_eth_dev *dev,
|
||||
continue;
|
||||
dev_cb = *cb_lst;
|
||||
cb_lst->active = 1;
|
||||
if (cb_arg != NULL)
|
||||
dev_cb.cb_arg = (void *) cb_arg;
|
||||
|
||||
rte_spinlock_unlock(&rte_eth_dev_cb_lock);
|
||||
dev_cb.cb_fn(dev->data->port_id, dev_cb.event,
|
||||
dev_cb.cb_arg);
|
||||
|
@ -3030,6 +3030,7 @@ enum rte_eth_event_type {
|
||||
/**< queue state event (enabled/disabled) */
|
||||
RTE_ETH_EVENT_INTR_RESET,
|
||||
/**< reset interrupt event, sent to VF on PF reset */
|
||||
RTE_ETH_EVENT_VF_MBOX, /**< message from the VF received by PF */
|
||||
RTE_ETH_EVENT_MAX /**< max value of this enum */
|
||||
};
|
||||
|
||||
@ -3051,6 +3052,11 @@ typedef void (*rte_eth_dev_cb_fn)(uint8_t port_id, \
|
||||
* @param cb_arg
|
||||
* Pointer to the parameters for the registered callback.
|
||||
*
|
||||
* The user data is overwritten in the case of RTE_ETH_EVENT_VF_MBOX.
|
||||
* This even occurs when a message from the VF is received by the PF.
|
||||
* The user data is overwritten with struct rte_pmd_ixgbe_mb_event_param.
|
||||
* This struct is defined in rte_pmd_ixgbe.h.
|
||||
*
|
||||
* @return
|
||||
* - On success, zero.
|
||||
* - On failure, a negative value.
|
||||
@ -3089,12 +3095,16 @@ int rte_eth_dev_callback_unregister(uint8_t port_id,
|
||||
* Pointer to struct rte_eth_dev.
|
||||
* @param event
|
||||
* Eth device interrupt event type.
|
||||
* @param cb_arg
|
||||
* Update callback parameter to pass data back to user application.
|
||||
* This allows the user application to decide if a particular function
|
||||
* is permitted or not.
|
||||
*
|
||||
* @return
|
||||
* void
|
||||
*/
|
||||
void _rte_eth_dev_callback_process(struct rte_eth_dev *dev,
|
||||
enum rte_eth_event_type event);
|
||||
enum rte_eth_event_type event, void *cb_arg);
|
||||
|
||||
/**
|
||||
* When there is no rx packet coming in Rx Queue for a long time, we can
|
||||
|
Loading…
x
Reference in New Issue
Block a user