- 论坛徽章:
- 1
|
回复 1# chishanmingshen
我这里举个例子,只说明寄存器与SPEC之间的对应关系,
我这里用的代码是从这里igxbe source code下载的,我这里的SPEC是从82599 dev manual
下载的,这里只用 ixgbe_intr来说明。
- /**
- * ixgbe_intr - legacy mode Interrupt Handler
- * @irq: interrupt number
- * @data: pointer to a network interface device structure
- **/
- static irqreturn_t ixgbe_intr(int irq, void *data)
- {
- struct ixgbe_adapter *adapter = data;
- struct ixgbe_hw *hw = &adapter->hw;
- struct ixgbe_q_vector *q_vector = adapter->q_vector[0];
- u32 eicr;
- /*
- * Workaround for silicon errata #26 on 82598. Mask the interrupt
- * before the read of EICR.
- */
- IXGBE_WRITE_REG(hw, IXGBE_EIMC, IXGBE_IRQ_CLEAR_MASK);
- /* for NAPI, using EIAM to auto-mask tx/rx interrupt bits on read
- * therefore no explicit interrupt disable is necessary */
- eicr = IXGBE_READ_REG(hw, IXGBE_EICR);
- if (!eicr) {
- /*
- * shared interrupt alert!
- * make sure interrupts are enabled because the read will
- * have disabled interrupts due to EIAM
- * finish the workaround of silicon errata on 82598. Unmask
- * the interrupt that we masked before the EICR read.
- */
- if (!test_bit(__IXGBE_DOWN, &adapter->state))
- ixgbe_irq_enable(adapter, true, true);
- return IRQ_NONE; /* Not our interrupt */
- }
- if (eicr & IXGBE_EICR_LSC)
- ixgbe_check_lsc(adapter);
- switch (hw->mac.type) {
- case ixgbe_mac_82599EB:
- case ixgbe_mac_X540:
- if (eicr & IXGBE_EICR_ECC) {
- e_info(link, "Received unrecoverable ECC Err,"
- "initiating reset.\n");
- adapter->flags2 |= IXGBE_FLAG2_RESET_REQUESTED;
- ixgbe_service_event_schedule(adapter);
- IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_ECC);
- }
- ixgbe_check_sfp_event(adapter, eicr);
- ixgbe_check_overtemp_event(adapter, eicr);
- break;
- default:
- break;
- }
- ixgbe_check_fan_failure(adapter, eicr);
- #ifdef HAVE_PTP_1588_CLOCK
- if (unlikely(eicr & IXGBE_EICR_TIMESYNC))
- ixgbe_ptp_check_pps_event(adapter, eicr);
- #endif
- /* would disable interrupts here but EIAM disabled it */
- napi_schedule(&q_vector->napi);
- /*
- * re-enable link(maybe) and non-queue interrupts, no flush.
- * ixgbe_poll will re-enable the queue interrupts
- */
- if (!test_bit(__IXGBE_DOWN, &adapter->state))
- ixgbe_irq_enable(adapter, false, false);
- return IRQ_HANDLED;
- }
复制代码 这上面有几个读写寄存器的,
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与源代码对应起来了。
不知道这个是否回答了你的问题。谢谢。
|
|