背景
- DPDK下的WX网卡万兆接口在DNS reply源认证功能测试中,出现接口不发包的现象。
- 通过接口DOWN->UP操作后,可恢复状态,重复步骤1操作稳定复现。
环境
kylin-4.19
DPDK19.11.14
问题分析
1.确认不发包位置
带业务的环境中,首先要确认出不发包的位置,通过DPDK调试工具定位发现,接口的上层逻辑在调用驱动发送接口正常,但在异常时,驱动反压,回弹发送数量0,排除了业务层发送问题。
通过GDB跟踪DPDK设备的发送接口txgbe_xmit_pkts(具体使用的发送接口可通过查看rte_eth_devices的设备信息获取)
txgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
uint16_t nb_pkts)
{
...
...
/*
* Make sure there are enough TX descriptors available to
* transmit the entire packet.
* nb_used better be less than or equal to txq->tx_free_thresh
*/
if (nb_used > txq->nb_tx_free) {
PMD_TX_FREE_LOG(DEBUG,
"Not enough free TX descriptors "
"nb_used=%4u nb_free=%4u "
"(port=%d queue=%d)",
nb_used, txq->nb_tx_free,
txq->port_id, txq->queue_id);
if (txgbe_xmit_cleanup(txq) != 0) {
/* Could not clean any descriptors */
if (nb_tx == 0)
return 0;
goto end_of_tx;
}
/* nb_used better be <= txq->tx_free_thresh */
if (unlikely(nb_used > txq->tx_free_thresh)) {
PMD_TX_FREE_LOG(DEBUG,
"The number of descriptors needed to "
"transmit the packet exceeds the "
"RS bit threshold. This will impact "
"performance."
"nb_used=%4u nb_free=%4u "
"tx_free_thresh=%4u. "
"(port=%d queue=%d)",
nb_used, txq->nb_tx_free,
txq->tx_free_thresh,
txq->port_id, txq->queue_id);
/*
* Loop here until there are enough TX
* descriptors or until the ring cannot be
* cleaned.
*/
while (nb_used > txq->nb_tx_free) {
if (txgbe_xmit_cleanup(txq) != 0) {
/*
* Could not clean any
* descriptors
*/
if (nb_tx == 0)
return 0;
goto end_of_tx;
}
}
}
}
/*
* By now there are enough free TX descriptors to transmit
* the packet.
*/
...
...
}
发现在异常是,接口调用直接会到空闲描述符不够使用的逻辑中,并在txgbe_xmit_cleanup函数调用返回失败。
static inline int
txgbe_xmit_cleanup(struct txgbe_tx_queue *txq)
{
...
...
if (desc_to_clean_to >= nb_tx_desc)
desc_to_clean_to =