免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 5302 | 回复: 4
打印 上一主题 下一主题

[网络子系统] 关于网卡data sheet [复制链接]

论坛徽章:
1
15-16赛季CBA联赛之新疆
日期:2017-03-09 12:33:45
1 [报告]
发表于 2013-03-13 09:26 |显示全部楼层
回复 1# chishanmingshen


    我这里举个例子,只说明寄存器与SPEC之间的对应关系,
    我这里用的代码是从这里igxbe source code下载的,我这里的SPEC是从82599 dev manual
    下载的,这里只用 ixgbe_intr来说明。

  1. /**
  2. * ixgbe_intr - legacy mode Interrupt Handler
  3. * @irq: interrupt number
  4. * @data: pointer to a network interface device structure
  5. **/
  6. static irqreturn_t ixgbe_intr(int irq, void *data)
  7. {
  8.         struct ixgbe_adapter *adapter = data;
  9.         struct ixgbe_hw *hw = &adapter->hw;
  10.         struct ixgbe_q_vector *q_vector = adapter->q_vector[0];
  11.         u32 eicr;

  12.         /*
  13.          * Workaround for silicon errata #26 on 82598.  Mask the interrupt
  14.          * before the read of EICR.
  15.          */
  16.         IXGBE_WRITE_REG(hw, IXGBE_EIMC, IXGBE_IRQ_CLEAR_MASK);

  17.         /* for NAPI, using EIAM to auto-mask tx/rx interrupt bits on read
  18.          * therefore no explicit interrupt disable is necessary */
  19.         eicr = IXGBE_READ_REG(hw, IXGBE_EICR);
  20.         if (!eicr) {
  21.                 /*
  22.                  * shared interrupt alert!
  23.                  * make sure interrupts are enabled because the read will
  24.                  * have disabled interrupts due to EIAM
  25.                  * finish the workaround of silicon errata on 82598.  Unmask
  26.                  * the interrupt that we masked before the EICR read.
  27.                  */
  28.                 if (!test_bit(__IXGBE_DOWN, &adapter->state))
  29.                         ixgbe_irq_enable(adapter, true, true);
  30.                 return IRQ_NONE;        /* Not our interrupt */
  31.         }

  32.         if (eicr & IXGBE_EICR_LSC)
  33.                 ixgbe_check_lsc(adapter);

  34.         switch (hw->mac.type) {
  35.         case ixgbe_mac_82599EB:
  36.         case ixgbe_mac_X540:
  37.                 if (eicr & IXGBE_EICR_ECC) {
  38.                         e_info(link, "Received unrecoverable ECC Err,"
  39.                                "initiating reset.\n");
  40.                         adapter->flags2 |= IXGBE_FLAG2_RESET_REQUESTED;
  41.                         ixgbe_service_event_schedule(adapter);
  42.                         IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_ECC);
  43.                 }
  44.                 ixgbe_check_sfp_event(adapter, eicr);
  45.                 ixgbe_check_overtemp_event(adapter, eicr);
  46.                 break;
  47.         default:
  48.                 break;
  49.         }

  50.         ixgbe_check_fan_failure(adapter, eicr);
  51. #ifdef HAVE_PTP_1588_CLOCK
  52.         if (unlikely(eicr & IXGBE_EICR_TIMESYNC))
  53.             ixgbe_ptp_check_pps_event(adapter, eicr);
  54. #endif

  55.         /* would disable interrupts here but EIAM disabled it */
  56.         napi_schedule(&q_vector->napi);

  57.         /*
  58.          * re-enable link(maybe) and non-queue interrupts, no flush.
  59.          * ixgbe_poll will re-enable the queue interrupts
  60.          */
  61.         if (!test_bit(__IXGBE_DOWN, &adapter->state))
  62.                 ixgbe_irq_enable(adapter, false, false);

  63.         return IRQ_HANDLED;
  64. }
复制代码
这上面有几个读写寄存器的,
      eicr = IXGBE_READ_REG(hw, IXGBE_EICR);
      IXGBE_EICR 这个参数在代码中被定义为
#define IXGBE_EICR                0x00800
       而在SPEC中被定义为在Page 461 0x800

    而后面检查
        if (eicr & IXGBE_EICR_LSC)
                ixgbe_check_lsc(adapter);

    IXGBE_EICR_LSC这个值被定义为
    #define IXGBE_EICR_LSC                0x00100000 /* Link Status Change */
   
   SPEC中把LSC这一位是bit20 正好是这个值的对应。
     这样,就可以把SPEC与源代码对应起来了。

   不知道这个是否回答了你的问题。谢谢。

      
     
   

论坛徽章:
1
15-16赛季CBA联赛之新疆
日期:2017-03-09 12:33:45
2 [报告]
发表于 2013-03-13 10:07 |显示全部楼层
回复 6# chishanmingshen


    我在代码中没有看到关于你说的什么Base Address0,Base Address5这样的代码,不知道你具体指什么?

论坛徽章:
1
15-16赛季CBA联赛之新疆
日期:2017-03-09 12:33:45
3 [报告]
发表于 2013-03-13 10:33 |显示全部楼层
回复 8# chishanmingshen


    你说这个,那与整个LINUX内核代码的PCI有关,最初这个是在LINUX内核初始化PCI的时候设定的,原来的PCI的整个规范中有关于外围设备与CPU总线的地址映射关系。这个是有专门的寄存器处理的,具体现在已经不太记的清楚了,但在前面说的SPEC中有对应的,就是Page 426上面有讲到这个地址可以被改写为总线地址,这个是LINUX初始化PCI的时候进行设定的,这样可以把片上的内存与整个CPU的控制总线地址进行统一管理。而你说的到了probe的阶段,其实就是读出这个寄存器的值进行物理内存地址,到虚拟内存地址的关联。如果你要解决这个问题,最好是去读LINUX中关于PCI的内容
      浅谈Linux PCI设备驱动(一) 浅谈Linux PCI设备驱动(二)

论坛徽章:
1
15-16赛季CBA联赛之新疆
日期:2017-03-09 12:33:45
4 [报告]
发表于 2013-03-13 12:55 |显示全部楼层
回复 10# chishanmingshen


    整个代码中,这几个宏就没有用到。所以,这个本身原来是出于哪里就不知道了。

论坛徽章:
1
15-16赛季CBA联赛之新疆
日期:2017-03-09 12:33:45
5 [报告]
发表于 2013-03-13 15:22 |显示全部楼层
回复 12# chishanmingshen


    加我QQ:576297488
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP