pf_ring DNA接收流程代码分析
经过一个月的学习,对pf_ring DNA的内核部分有了一些认识,本文侧重pf_ring对ixgbe的改动分析。
先说一说接收流程吧,流程如下:
其中,硬中断处理函数是ixgbe_msix_clean_rings( );软中断处理函数是net_rx_action( )。
pf_ring对ixgbe的改动主要在ixgbe_poll()和ixgbe_clean_rx_irq()中。
在ixgbe_poll( )中遍历每个队列并轮询处理数据包,代码如下。
int ixgbe_poll(struct napi_struct *napi, int budget)
{
struct ixgbe_q_vector *q_vector =
container_of(napi, struct ixgbe_q_vector, napi);
struct ixgbe_adapter *adapter = q_vector->adapter;
struct ixgbe_ring *ring;
int per_ring_budget;
bool clean_complete = true; #if defined(CONFIG_DCA) || defined(CONFIG_DCA_MODULE) //如果设定直接缓存访问技术
if (adapter->flags & IXGBE_FLAG_DCA_ENABLED)
ixgbe_update_dca(q_vector); //怎么一点儿性能提升都没有呢? #endif
ixgbe_for_each_ring(ring, q_vector->tx)
clean_complete &= ixgbe_clean_tx_irq(q_vector, ring); //清理回收发送所用资源 #ifdef CONFIG_NET_RX_BUSY_POLL
if (!ixgbe_qv_lock_napi(q_vector))
return budget;
#endif /* attempt to distribute budget to each queue fairly, but don't allow
* the budget to go below 1 because we'll exit polling */
if (q_vector->rx.count > )
per_ring_budget = max(budget/q_vector->rx.count, );
else
per_ring_budget = budget; //默认为64,执行else分支
//for (ring = (q_vector->rx).ring; ring != NULL; ring = ring->next) ixgbe_for_each_ring(ring, q_vector->rx) //循环遍历每个ring
clean_complete &= (ixgbe_clean_rx_irq(q_vector, ring, per_ring_budget)
< per_ring_budget); //判断已处理包数是否小于事先设定值 #ifdef CONFIG_NET_RX_BUSY_POLL
ixgbe_qv_unlock_napi(q_vector);
#endif #ifndef HAVE_NETDEV_NAPI_LIST
if (!netif_running(adapter->netdev))
clean_complete = true; #endif
/* If all work not completed, return budget and keep polling 如果未全部完成*/
if (!clean_complete)
return budget; /* all work done, exit the polling mode 如果已经全部完成 */
napi_complete(napi); //标记NAPI完成
if (adapter->rx_itr_setting == )
ixgbe_set_itr(q_vector); //根据状况调整中断频率
if (!test_bit(__IXGBE_DOWN, &adapter->state)) //如果不是down状态
ixgbe_irq_enable_queues(adapter, ((u64) << q_vector->v_idx)); ////使能中断队列 return ;
}
pf_ring的修改只有一处:
#ifdef ENABLE_DNA
if(!adapter->dna.dna_enabled) //如果没有启动DNA
#endif
if (!test_bit(__IXGBE_DOWN, &adapter->state)) //如果不是down状态
ixgbe_irq_enable_queues(adapter, ((u64)1 << q_vector->v_idx)); //使能中断队列
//也就是说,DNA模式下不会执行使能中断队列
ixgbe_clean_rx_irq( )函数的代码如下:
static int ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector, //把ring buffer的内容取出来转成sk_buff包
struct ixgbe_ring *rx_ring,
int budget)
{
unsigned int total_rx_bytes = , total_rx_packets = ;
#ifdef IXGBE_FCOE
int ddp_bytes = ;
#endif /* IXGBE_FCOE */
u16 cleaned_count = ixgbe_desc_unused(rx_ring); //计算可清除的descriptors个数(打印其值为0,说明descriptors使用非常紧张) do {
union ixgbe_adv_rx_desc *rx_desc; ////描述符
struct sk_buff *skb; //套接字缓冲区 /* return some buffers to hardware, one at a time is too slow */
if (cleaned_count >= IXGBE_RX_BUFFER_WRITE) { //超过16个
ixgbe_alloc_rx_buffers(rx_ring, cleaned_count); //替换出已使用的descriptors,并修改next_to_use值
cleaned_count = ;
}
//next_to_clean是可以清除的描述符编号,也就是网卡对描述符该做的工作已经做完,可以传递给上层协议
rx_desc = IXGBE_RX_DESC(rx_ring, rx_ring->next_to_clean); //将next_to_clean序号转换成相应的描述符 if (!ixgbe_test_staterr(rx_desc, IXGBE_RXD_STAT_DD)) //测试Descriptor Done位是否为1(表示网卡硬件已经处理完毕)
break; // 如果desc的DD位为0,则结束整个while循环, 也就是说,只有在DD位为1时才能往下执行 /*
* This memory barrier is needed to keep us from reading
* any other fields out of the rx_desc until we know the
* RXD_STAT_DD bit is set
*/
rmb(); /* retrieve a buffer from the ring 根据描述符从接收环中提取一个缓冲单元*/
skb = ixgbe_fetch_rx_buffer(rx_ring, rx_desc); //分配skb /* exit if we failed to retrieve a buffer */
if (!skb)
break; cleaned_count++; /* place incomplete frames back on ring for completion */
if (ixgbe_is_non_eop(rx_ring, rx_desc, skb)) //返回false表示EOP位为1,并修改next_to_clean值,直接影响下一次循环的rx_desc
continue; //如果EOP为0,则结束本次循环,也就是说,只有在EOP为1时才能继续往下执行 /* verify the packet layout is correct */
if (ixgbe_cleanup_headers(rx_ring, rx_desc, skb)) //检查数据包的header
continue; //如果header有误则返回true并释放skb /* probably a little skewed due to removing CRC */
total_rx_bytes += skb->len; /* populate 填充 checksum, timestamp, VLAN, and protocol */
ixgbe_process_skb_fields(rx_ring, rx_desc, skb); #ifdef IXGBE_FCOE
/* if ddp, not passing to ULD unless for FCP_RSP or error */
if (ixgbe_rx_is_fcoe(rx_ring, rx_desc)) {
ddp_bytes = ixgbe_fcoe_ddp(q_vector->adapter,
rx_desc, skb);
if (!ddp_bytes) {
dev_kfree_skb_any(skb);
#ifndef NETIF_F_GRO
netdev_ring(rx_ring)->last_rx = jiffies;
#endif
continue;
}
} #endif /* IXGBE_FCOE */
#ifdef CONFIG_NET_RX_BUSY_POLL
skb_mark_napi_id(skb, &q_vector->napi);
#endif
ixgbe_rx_skb(q_vector, rx_ring, rx_desc, skb); //调用netif_receive_skb接收数据包 /* update budget accounting */
total_rx_packets++;
} while (likely(total_rx_packets < budget)); //是否已经达到设备的budget #ifdef IXGBE_FCOE
/* include DDPed FCoE data */
if (ddp_bytes > ) {
unsigned int mss; mss = netdev_ring(rx_ring)->mtu - sizeof(struct fcoe_hdr) -
sizeof(struct fc_frame_header) -
sizeof(struct fcoe_crc_eof);
if (mss > )
mss &= ~;
total_rx_bytes += ddp_bytes;
total_rx_packets += DIV_ROUND_UP(ddp_bytes, mss);
} #endif /* IXGBE_FCOE */
u64_stats_update_begin(&rx_ring->syncp);
rx_ring->stats.packets += total_rx_packets;
rx_ring->stats.bytes += total_rx_bytes;
u64_stats_update_end(&rx_ring->syncp);
q_vector->rx.total_packets += total_rx_packets;
q_vector->rx.total_bytes += total_rx_bytes; if (cleaned_count) //经过清理之后,现在就有cleaned_count个DMA描述符可供网卡硬件重新使用
ixgbe_alloc_rx_buffers(rx_ring, cleaned_count); //分配clean_count个page建立流式映射 #ifndef IXGBE_NO_LRO
ixgbe_lro_flush_all(q_vector); #endif /* IXGBE_NO_LRO */
return total_rx_packets;
}
而pf_ring对ixgbe_clean_rx_irq( )函数的改动非常大:
static int ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector,
struct ixgbe_ring *rx_ring,
int budget)
{
unsigned int total_rx_bytes = 0, total_rx_packets = 0;
#ifdef IXGBE_FCOE
int ddp_bytes = 0;
#endif /* IXGBE_FCOE */
u16 cleaned_count = ixgbe_desc_unused(rx_ring);
#ifdef ENABLE_DNA
struct ixgbe_adapter *adapter = q_vector->adapter;
if(adapter->dna.dna_enabled)
return(dna_ixgbe_clean_rx_irq(q_vector, rx_ring, budget)); //抛弃intel原有处理流程,调用PF_RING DNA独有的清理函数
#endif .......................... }
再来秀一秀dna_ixgbe_clean_rx_irq()函数吧:
static bool dna_ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector,
struct ixgbe_ring *rx_ring, int budget) {
union ixgbe_adv_rx_desc *rx_desc, *shadow_rx_desc, *next_rx_desc;
u32 staterr;
u16 i, num_laps = , last_cleaned_idx;
struct ixgbe_adapter *adapter = q_vector->adapter;
struct ixgbe_hw *hw = &adapter->hw;
unsigned int total_rx_packets = ; last_cleaned_idx = i = IXGBE_READ_REG(hw, IXGBE_RDT(rx_ring->reg_idx)); //读取tail
if(++i == rx_ring->count)
i = ; rx_ring->next_to_clean = i; //把i赋给next_to_clean //i = IXGBE_READ_REG(hw, IXGBE_RDT(rx_ring->reg_idx));
rx_desc = IXGBE_RX_DESC(rx_ring, i); //得到描述符
staterr = le32_to_cpu(rx_desc->wb.upper.status_error); //读取描述符状态 if(rx_ring->dna.queue_in_use) { //如果应用程序正在使用该接收队列
/*
A userland application is using the queue so it's not time to
mess up 弄乱 with indexes but just to wakeup apps (if waiting)
*/ /* trick for appplications calling poll/select directly (indexes not in sync of one position at most) */
if (!(staterr & IXGBE_RXD_STAT_DD)) {
u16 next_i = i;
if(++next_i == rx_ring->count) next_i = ;
next_rx_desc = IXGBE_RX_DESC(rx_ring, next_i);
staterr = le32_to_cpu(next_rx_desc->wb.upper.status_error);
} if(staterr & IXGBE_RXD_STAT_DD) {
if(unlikely(enable_debug))
printk(KERN_INFO "DNA: got a packet [index=%d]!\n", i); if(waitqueue_active(&rx_ring->dna.rx_tx.rx.packet_waitqueue)) {
wake_up_interruptible(&rx_ring->dna.rx_tx.rx.packet_waitqueue);
rx_ring->dna.rx_tx.rx.interrupt_received = ; if(unlikely(enable_debug))
printk("%s(%s): woken up ring=%d, [slot=%d] XXX\n",
__FUNCTION__, rx_ring->netdev->name,
rx_ring->reg_idx, i);
}
} // goto dump_stats;
return(!!budget);
} /* Only 82598 needs kernel housekeeping 家务 (82599 does not need that thanks
to the drop bit), as the drop flag does not seem to work
只有82598网卡因drop标志位似乎不能工作而需要做杂务处理,
而82599不需要继续执行
*/
if(adapter->hw.mac.type != ixgbe_mac_82598EB)
return(!!budget); //可是,82599网卡怎么收包呢? if( /* staterr || */ enable_debug) {
printk("[DNA] %s(): %s@%d [used=%d][idx=%d][next_to_use=%u][#unused=%d][staterr=%d][full=%d][pkt_ptr=%llu]\n", __FUNCTION__,
rx_ring->netdev->name, rx_ring->queue_index,
rx_ring->dna.queue_in_use, i, rx_ring->next_to_use,
ixgbe_desc_unused(rx_ring), staterr, dna_ixgbe_rx_dump(rx_ring), rx_desc->read.pkt_addr);
} /*
This RX queue is not in use 用户空间的程序没有使用该接收队列 IMPORTANT
We need to poll queues not in use as otherwise they will stop the operations
also on queues where there is an application running that consumes the packets
*/
while(staterr & IXGBE_RXD_STAT_DD) { //轮询DD状态的描述符
shadow_rx_desc = IXGBE_RX_DESC(rx_ring, i+rx_ring->count); //影子描述符
rx_desc->wb.upper.status_error = , last_cleaned_idx = i;
rx_desc->read.hdr_addr = shadow_rx_desc->read.hdr_addr, rx_desc->read.pkt_addr = shadow_rx_desc->read.pkt_addr; //从影子描述符中取出数据包和包头的DMA地址 rmb(); //内存屏障,保证代码执行顺序 // REMOVE BELOW
// ixgbe_release_rx_desc(rx_ring, i); /* Not needed */ i++, num_laps++, budget--;
if(i == rx_ring->count) //环状数组,逆转
i = ; rx_desc = IXGBE_RX_DESC(rx_ring, i); //取出描述符
prefetch(rx_desc); //预取描述符
staterr = le32_to_cpu(rx_desc->wb.upper.status_error); if(budget == ) break;
} rx_ring->stats.packets += total_rx_packets;
// rx_ring->stats.bytes += total_rx_bytes;
q_vector->rx.total_packets += total_rx_packets;
// q_vector->rx.total_bytes += total_rx_bytes; /* Update register 更新寄存器 */
rx_ring->next_to_clean = i, IXGBE_WRITE_REG(&adapter->hw, IXGBE_RDT(rx_ring->reg_idx), last_cleaned_idx); if(unlikely(enable_debug)) { //忽略
int j=, full = , other = , null_dma = ;
struct ixgbe_rx_buffer *bi; for(j=; j<rx_ring->count; j++) {
rx_desc = IXGBE_RX_DESC(rx_ring, j);
prefetch(rx_desc);
staterr = le32_to_cpu(rx_desc->wb.upper.status_error); bi = &rx_ring->rx_buffer_info[i]; if(staterr & IXGBE_RXD_STAT_DD)
full++; //DD状态
else if(staterr)
other++; //非DD状态 if(bi->dma == ) null_dma++;
} printk("[DNA] %s(): %s@%d [laps=%d][budget=%d][full=%d/other=%d][next_to_clean=%u][next_to_use=%d][#unused=%d][null_dma=%d]\n",
__FUNCTION__,
rx_ring->netdev->name, rx_ring->queue_index,
num_laps, budget, full, other,
rx_ring->next_to_clean, rx_ring->next_to_use,
ixgbe_desc_unused(rx_ring), null_dma);
} return(!!budget);
}
其实,还有个很重要的函数ixgbe_alloc_rx_buffers( ),主要用来分配DMA page映射网卡的FIFO,代码如下。
void ixgbe_alloc_rx_buffers(struct ixgbe_ring *rx_ring, u16 cleaned_count)
{
union ixgbe_adv_rx_desc *rx_desc;
struct ixgbe_rx_buffer *bi;
u16 i = rx_ring->next_to_use; //接收环中下一个可使用的描述符编号, next_to_use之后是目前可以DMA映射与传输的描述符 /* nothing to do */
if (!cleaned_count) //如果需要替换的缓存单元个数为0
return; rx_desc = IXGBE_RX_DESC(rx_ring, i); //取第i个描述符
bi = &rx_ring->rx_buffer_info[i]; //取第i个缓存单元
i -= rx_ring->count; //减去count do {
#ifdef CONFIG_IXGBE_DISABLE_PACKET_SPLIT //禁止包分割
if (!ixgbe_alloc_mapped_skb(rx_ring, bi)) //分配rx_buf_len即2048字节来建立流式映射
#else //默认情形,允许包分割
if (!ixgbe_alloc_mapped_page(rx_ring, bi)) //分配page来建立流式映射,使用的是高端内存 #endif
break; /* 即便buffer_addrs没变,也要更新desc,因为每次硬件写回会擦除这个buffer_addrs信息
* Refresh the desc even if buffer_addrs didn't change
* because each write-back erases 擦除 this info.
*/
#ifdef CONFIG_IXGBE_DISABLE_PACKET_SPLIT //禁止包分割
rx_desc->read.pkt_addr = cpu_to_le64(bi->dma);
#else //默认情况下允许包分割
rx_desc->read.pkt_addr = cpu_to_le64(bi->dma + bi->page_offset); //设置pkt_addr
#endif rx_desc++; //指向下一个接收描述符
bi++; //指向下一个接收缓存单元
i++; //指向下一个接收描述符编号
if (unlikely(!i)) { //如果下一个接收描述符编号i为0
rx_desc = IXGBE_RX_DESC(rx_ring, ); //描述符为0
bi = rx_ring->rx_buffer_info; //缓冲单元指向缓冲区起始位置
i -= rx_ring->count; //65536减去count
} /* clear the hdr_addr for the next_to_use descriptor */
rx_desc->read.hdr_addr = ; //清除下一个描述符的hdr_addr cleaned_count--; //需要替换的缓存单元个数减一
} while (cleaned_count); i += rx_ring->count; //加上count if (rx_ring->next_to_use != i) //如果next_to_use与i不一致
ixgbe_release_rx_desc(rx_ring, i); //更新next_to_use和next_to_alloc变量
}
而pf_ring也采用了它自己的函数dna_ixgbe_alloc_rx_buffers:
#ifdef ENABLE_DNA
struct ixgbe_adapter *adapter = netdev_priv(rx_ring->netdev); if(adapter->dna.dna_enabled) {
if(rx_ring->netdev)
dna_ixgbe_alloc_rx_buffers(rx_ring); //抛弃intel实现的方法,采用PF_RING DMA方式自己的内存分配方案
return;
}
#endif
void dna_ixgbe_alloc_rx_buffers(struct ixgbe_ring *rx_ring) {
union ixgbe_adv_rx_desc *rx_desc, *shadow_rx_desc;
struct ixgbe_rx_buffer *bi;
u16 i;
struct ixgbe_adapter *adapter = netdev_priv(rx_ring->netdev);
struct ixgbe_hw *hw = &adapter->hw;
u16 cache_line_size;
struct ixgbe_ring *tx_ring = adapter->tx_ring[rx_ring->queue_index];
struct pfring_hooks *hook = (struct pfring_hooks*)rx_ring->netdev->pfring_ptr;
mem_ring_info rx_info = {};
mem_ring_info tx_info = {};
int num_slots_per_page; /* Check if the memory has been already allocated */
if(rx_ring->dna.memory_allocated) return; /* nothing to do or no valid netdev defined */
if (!netdev_ring(rx_ring))
return; if (!hook) {
printk("[DNA] WARNING The PF_RING module is NOT loaded.\n");
printk("[DNA] WARNING Please load it, before loading this module\n");
return;
} init_waitqueue_head(&rx_ring->dna.rx_tx.rx.packet_waitqueue); cache_line_size = cpu_to_le16(IXGBE_READ_PCIE_WORD(hw, IXGBE_PCI_DEVICE_CACHE_LINE_SIZE));
cache_line_size &= 0x00FF;
cache_line_size *= PCI_DEVICE_CACHE_LINE_SIZE_BYTES;
if(cache_line_size == ) cache_line_size = ; if(unlikely(enable_debug))
printk("%s(): pci cache line size %d\n",__FUNCTION__, cache_line_size); rx_ring->dna.packet_slot_len = ALIGN(rx_ring->rx_buf_len, cache_line_size); //1600 slot长度
rx_ring->dna.packet_num_slots = rx_ring->count; //8192 slot个数 rx_ring->dna.tot_packet_memory = PAGE_SIZE << DNA_MAX_CHUNK_ORDER; //4096*32=131072 全部包内存 这个有什么用? num_slots_per_page = rx_ring->dna.tot_packet_memory / rx_ring->dna.packet_slot_len; //131072/1600=81 rx_ring->dna.num_memory_pages = (rx_ring->dna.packet_num_slots + num_slots_per_page-) / num_slots_per_page; //(8192+81-1)/81=102 /* Packet Split disabled in DNA mode */
//if (ring_is_ps_enabled(rx_ring)) {
/* data will be put in this buffer */
/* Original fuction allocate PAGE_SIZE/2 for this buffer*/
// rx_ring->dna.packet_slot_len += PAGE_SIZE/2;
//} if(unlikely(enable_debug))
printk("%s(): RX dna.packet_slot_len=%d tot_packet_memory=%d num_memory_pages=%u num_slots_per_page=%d\n",
__FUNCTION__,
rx_ring->dna.packet_slot_len, //
rx_ring->dna.tot_packet_memory, //
rx_ring->dna.num_memory_pages, //
num_slots_per_page); // for(i=; i<rx_ring->dna.num_memory_pages; i++) { //102次
rx_ring->dna.rx_tx.rx.packet_memory[i] = //slot槽
alloc_contiguous_memory(&rx_ring->dna.tot_packet_memory, //4096*32字节
&rx_ring->dna.mem_order, //返回页数
rx_ring->q_vector->numa_node); //指定numa节点 if (rx_ring->dna.rx_tx.rx.packet_memory[i] == ) { //如果分配失败
printk("\n\n%s() ERROR: not enough memory for RX DMA ring!!\n\n\n",
__FUNCTION__);
return;
} if(unlikely(enable_debug))
printk("[DNA] %s(): Successfully allocated RX %u@%u bytes at 0x%08lx [slot_len=%d]\n",
__FUNCTION__, rx_ring->dna.tot_packet_memory, i,
rx_ring->dna.rx_tx.rx.packet_memory[i], rx_ring->dna.packet_slot_len);
} if(unlikely(enable_debug))
printk("[DNA] %s(): %s@%d ptr=%p memory allocated on node %d\n", __FUNCTION__,
rx_ring->netdev->name, rx_ring->queue_index, rx_ring, rx_ring->q_vector->numa_node); for(i=; i < rx_ring->count; i++) { //
u_int offset, page_index;
char *pkt; page_index = i / num_slots_per_page; // i/81
offset = (i % num_slots_per_page) * rx_ring->dna.packet_slot_len;
pkt = (char *)(rx_ring->dna.rx_tx.rx.packet_memory[page_index] + offset); //DMA缓冲区的地址 /*
if(unlikely(enable_debug))
printk("[DNA] %s(): Successfully remapped RX %u@%u bytes at 0x%08lx [slot_len=%d][page_index=%u][offset=%u]\n",
__FUNCTION__, rx_ring->dna.tot_packet_memory, i,
rx_ring->dna.rx_tx.rx.packet_memory[i],
rx_ring->dna.packet_slot_len, page_index, offset);
*/ bi = &rx_ring->rx_buffer_info[i];
bi->skb = NULL;
rx_desc = IXGBE_RX_DESC(rx_ring, i); if(unlikely(enable_debug))
printk("%s(): Mapping RX slot %d of %d [pktaddr=%p][rx_desc=%p][offset=%u]\n",
__FUNCTION__, i, rx_ring->dna.packet_num_slots,
pkt, rx_desc, offset);
//为什么只是做了一次DMA流式映射呢???????????
bi->dma = pci_map_single(to_pci_dev(rx_ring->dev), pkt, //进行流式DMA映射
rx_ring->dna.packet_slot_len, //
PCI_DMA_BIDIRECTIONAL /* PCI_DMA_FROMDEVICE */ ); /* Packet Split disabled in DNA mode 禁止数据包分割*/
//if (!ring_is_ps_enabled(rx_ring)) {
rx_desc->read.hdr_addr = ;
rx_desc->read.pkt_addr = cpu_to_le64(bi->dma);
//} else {
// rx_desc->read.hdr_addr = cpu_to_le64(bi->dma);
// rx_desc->read.pkt_addr = cpu_to_le64(bi->dma + rx_ring->dna.packet_slot_len);
//} rx_desc->wb.upper.status_error = ; shadow_rx_desc = IXGBE_RX_DESC(rx_ring, i + rx_ring->count); //计算影子描述符表的地址
memcpy(shadow_rx_desc, rx_desc, sizeof(union ixgbe_adv_rx_desc));//把原描述符表全部复制到影子描述表 if(unlikely(enable_debug)) {
print_adv_rx_descr(rx_desc);
print_adv_rx_descr(shadow_rx_desc);
} ixgbe_release_rx_desc(rx_ring, i);
} /* for */ /* Shadow */
rx_desc = IXGBE_RX_DESC(rx_ring, ); /* Resetting index
rx_ring->next_to_use = the last slot where the next incoming packets can be copied (tail) */
ixgbe_release_rx_desc(rx_ring, rx_ring->count-);
/* rx_ring->next_to_clean = the slot where the next incoming packet will be read (head) */
rx_ring->next_to_clean = ; /* Register with PF_RING */ if(unlikely(enable_debug))
printk("[DNA] next_to_clean=%u/next_to_use=%u [register=%d]\n",
rx_ring->next_to_clean, rx_ring->next_to_use, IXGBE_READ_REG(hw, IXGBE_RDT(rx_ring->reg_idx))); /* Allocate TX memory */
tx_ring->dna.tot_packet_memory = rx_ring->dna.tot_packet_memory;
tx_ring->dna.packet_slot_len = rx_ring->dna.packet_slot_len;
tx_ring->dna.packet_num_slots = tx_ring->count;
tx_ring->dna.mem_order = rx_ring->dna.mem_order;
tx_ring->dna.num_memory_pages = (tx_ring->dna.packet_num_slots + num_slots_per_page-) / num_slots_per_page; dna_ixgbe_alloc_tx_buffers(tx_ring, hook); rx_info.packet_memory_num_chunks = rx_ring->dna.num_memory_pages;
rx_info.packet_memory_chunk_len = rx_ring->dna.tot_packet_memory;
rx_info.packet_memory_num_slots = rx_ring->dna.packet_num_slots;
rx_info.packet_memory_slot_len = rx_ring->dna.packet_slot_len;
rx_info.descr_packet_memory_tot_len = * rx_ring->size; tx_info.packet_memory_num_chunks = tx_ring->dna.num_memory_pages;
tx_info.packet_memory_chunk_len = tx_ring->dna.tot_packet_memory;
tx_info.packet_memory_num_slots = tx_ring->dna.packet_num_slots;
tx_info.packet_memory_slot_len = tx_ring->dna.packet_slot_len;
tx_info.descr_packet_memory_tot_len = * tx_ring->size;
//原来如此,通过调用函数 dna_device_handler,把驱动有关信息告诉pf_ring模块
hook->ring_dna_device_handler(add_device_mapping,
dna_v1,
&rx_info,
&tx_info,
rx_ring->dna.rx_tx.rx.packet_memory, //接收包内存
rx_ring->desc, /* Packet descriptors 接收包描述符内存 */
tx_ring->dna.rx_tx.tx.packet_memory, //发送包内存
tx_ring->desc, /* Packet descriptors 发送包描述符内存 */
(void*)rx_ring->netdev->mem_start, //物理网卡内存
rx_ring->netdev->mem_end - rx_ring->netdev->mem_start,
rx_ring->queue_index, /* Channel Id */
rx_ring->netdev,
rx_ring->dev, /* for DMA mapping */
dna_model(hw),
rx_ring->netdev->dev_addr,
&rx_ring->dna.rx_tx.rx.packet_waitqueue,
&rx_ring->dna.rx_tx.rx.interrupt_received,
(void*)rx_ring, (void*)tx_ring,
wait_packet_function_ptr,
notify_function_ptr); rx_ring->dna.memory_allocated = ; if(unlikely(enable_debug))
printk("[DNA] ixgbe: %s: Enabled DNA on queue %d [RX][size=%u][count=%d] [TX][size=%u][count=%d]\n",
rx_ring->netdev->name, rx_ring->queue_index, rx_ring->size, rx_ring->count, tx_ring->size, tx_ring->count);
#if 0
if(adapter->hw.mac.type != ixgbe_mac_82598EB)
ixgbe_irq_disable_queues(rx_ring->q_vector->adapter, ((u64) << rx_ring->queue_index));
#endif
}
pf_ring DNA接收流程代码分析的更多相关文章
- Openfire注册流程代码分析
Openfire注册流程代码分析 一.客户端/服务端注册用户流程 经过主机连接消息确认后,客户端共发送俩条XML完成注册过程.服务器返回两条XML. 注:IQ消息节点用于处理用户的注册.好友.分组.获 ...
- Ecshop的购物流程代码分析详细说明
Ecshop的购物流程代码分析详细说明 (2012-07-30 10:41:12) 转载▼ 标签: 购物车 结算中心 商品价格 ecshop ecshop购物流程 杂谈 分类: ECSHOP研究院 同 ...
- Linux Kernel文件系统写I/O流程代码分析(二)bdi_writeback
Linux Kernel文件系统写I/O流程代码分析(二)bdi_writeback 上一篇# Linux Kernel文件系统写I/O流程代码分析(一),我们看到Buffered IO,写操作写入到 ...
- Linux Kernel文件系统写I/O流程代码分析(一)
Linux Kernel文件系统写I/O流程代码分析(一) 在Linux VFS机制简析(二)这篇博客上介绍了struct address_space_operations里底层文件系统需要实现的操作 ...
- [Android]Android焦点流程代码分析
以下内容为原创,欢迎转载,转载请注明 来自天天博客:http://www.cnblogs.com/tiantianbyconan/p/7286503.html 通过View的View::focusSe ...
- 【Heritrix基础教程之4】开始一个爬虫抓取的全流程代码分析
在创建一个job后,就要开始job的运行,运行的全流程如下: 1.在界面上启动job 2.index.jsp 查看上述页面对应的源代码 <a href='"+request.getCo ...
- Linux内核二层数据包接收流程
本文主要讲解了Linux内核二层数据包接收流程,使用的内核的版本是2.6.32.27 为了方便理解,本文采用整体流程图加伪代码的方式从内核高层面上梳理了二层数据包接收的流程,希望可以对大家有所帮助.阅 ...
- VSM(Virtual Storage Manager) add new osd 代码分析
vsm add new osd 流程 后台获取可用设备 | 选择可用设备及osd相关信息等 | 点击add按钮,把准备部署的osd信息添加到需要部署的item列表中 | 点击submit按钮,添加it ...
- twemproxy接收流程探索——twemproxy代码分析正编
在这篇文章开始前,大家要做好一个小小的心理准备,由于twemproxy代码是一份优秀的c语言,为此,在twemproxy的代码中会大篇幅使用c指针.但是不论是普通类型的指针还是函数指针,都可以让我们这 ...
随机推荐
- iOS 成员变量和属性的区别
一. 成员变量 1.成员变量的作用范围: @public:在任何地方都能直接访问对象的成员变量 @private:只能在当前类的对象方法中直接访问,如果子类要访问需要调用父类的get/set方法 @p ...
- Bean\Entity\Model\POJO\Dto\EJB简单解析
一.Bean 对于Bean而言,只要是Java的类的就可以称为一个Bean, 更用在Spring上,被Spring管理的对象就可以将其称作为Bean. 它不仅仅可以包括对象的属性以及get,set方法 ...
- setlocale()函数测试当前语言的两个程序
http://www.cnblogs.com/cnyao/archive/2010/05/06/1729220.html setlocale()函数是用来配置地域信息的,原本以为这个也是windows ...
- Windows Server 2012 下安装MySQL 5.6 X64位包
WIN下的MySQL 5.6非MSI安装 查阅了官网一下,比较靠前的版本,都很少提供MSI 64位的版本,只有32位的版本,但是服务器上跑的自然是64位的系统为佳,在官网下了免编译的WIN 环境包,过 ...
- 正确使用索引(sql优化),limit分页优化,执行计划,慢日志查询
查看表相关命令 - 查看表结构 desc 表名- 查看生成表的SQL show create table 表名- 查看索引 show index from 表名 使用索引和不使用索引 由 ...
- springboot整合Ehcache
首先引入maven包: <dependency> <groupId>org.springframework.boot</groupId> <artifactI ...
- scrapy使用笔记
新建项目 在需要新建项目的目录下发指令 scrapy startproject MySpider 其中MySpider为工程的名字,会新建一个文件夹 进入工程目录 新建一个爬虫 scrapy gens ...
- 安卓手机开机键失灵,FASTBOOT模式ADB重启
安装ADB工具 CMD指令fastboot reboot
- mysql数据库补充知识7 索引原理与慢查询优化
一 介绍 为何要有索引? 一般的应用系统,读写比例在10:1左右,而且插入操作和一般的更新操作很少出现性能问题,在生产环境中,我们遇到最多的,也是最容易出问题的,还是一些复杂的查询操作,因此对查询语句 ...
- Django基础(三)_分页器、COOKIE与SESSION、FORM表单
分页器(paginator) 分页器的使用 >>> from django.core.paginator import Paginator >>> objects ...