sfc: Really allow RX checksum offload to be disabled
[safe/jmp/linux-2.6] / drivers / net / sfc / falcon.c
index 3cb7e61..865638b 100644 (file)
 
 /**
  * struct falcon_nic_data - Falcon NIC state
- * @next_buffer_table: First available buffer table id
  * @pci_dev2: The secondary PCI device if present
  * @i2c_data: Operations and state for I2C bit-bashing algorithm
- * @int_error_count: Number of internal errors seen recently
- * @int_error_expire: Time at which error count will be expired
  */
 struct falcon_nic_data {
-       unsigned next_buffer_table;
        struct pci_dev *pci_dev2;
        struct i2c_algo_bit_data i2c_data;
-
-       unsigned int_error_count;
-       unsigned long int_error_expire;
 };
 
 /**************************************************************************
@@ -127,12 +120,6 @@ MODULE_PARM_DESC(rx_xon_thresh_bytes, "RX fifo XON threshold");
  **************************************************************************
  */
 
-/* DMA address mask */
-#define FALCON_DMA_MASK DMA_BIT_MASK(46)
-
-/* TX DMA length mask (13-bit) */
-#define FALCON_TX_DMA_MASK (4096 - 1)
-
 /* Size and alignment of special buffers (4KB) */
 #define FALCON_BUF_SIZE 4096
 
@@ -310,8 +297,6 @@ static int falcon_alloc_special_buffer(struct efx_nic *efx,
                                       struct efx_special_buffer *buffer,
                                       unsigned int len)
 {
-       struct falcon_nic_data *nic_data = efx->nic_data;
-
        len = ALIGN(len, FALCON_BUF_SIZE);
 
        buffer->addr = pci_alloc_consistent(efx->pci_dev, len,
@@ -326,8 +311,8 @@ static int falcon_alloc_special_buffer(struct efx_nic *efx,
        memset(buffer->addr, 0xff, len);
 
        /* Select new buffer ID */
-       buffer->index = nic_data->next_buffer_table;
-       nic_data->next_buffer_table += buffer->entries;
+       buffer->index = efx->next_buffer_table;
+       efx->next_buffer_table += buffer->entries;
 
        EFX_LOG(efx, "allocating special buffers %d-%d at %llx+%x "
                "(virt %p phys %llx)\n", buffer->index,
@@ -884,8 +869,9 @@ static void falcon_handle_rx_event(struct efx_channel *channel,
                 * UDP/IPv4, then we can rely on the hardware checksum.
                 */
                checksummed =
-                       rx_ev_hdr_type == FSE_AB_RX_EV_HDR_TYPE_IPV4_TCP ||
-                       rx_ev_hdr_type == FSE_AB_RX_EV_HDR_TYPE_IPV4_UDP;
+                       efx->rx_checksum_enabled &&
+                       (rx_ev_hdr_type == FSE_AB_RX_EV_HDR_TYPE_IPV4_TCP ||
+                        rx_ev_hdr_type == FSE_AB_RX_EV_HDR_TYPE_IPV4_UDP);
        } else {
                falcon_handle_rx_not_ok(rx_queue, event, &rx_ev_pkt_ok,
                                        &discard);
@@ -1078,20 +1064,11 @@ void falcon_set_int_moderation(struct efx_channel *channel)
 
        /* Set timer register */
        if (channel->irq_moderation) {
-               /* Round to resolution supported by hardware.  The value we
-                * program is based at 0.  So actual interrupt moderation
-                * achieved is ((x + 1) * res).
-                */
-               channel->irq_moderation -= (channel->irq_moderation %
-                                           FALCON_IRQ_MOD_RESOLUTION);
-               if (channel->irq_moderation < FALCON_IRQ_MOD_RESOLUTION)
-                       channel->irq_moderation = FALCON_IRQ_MOD_RESOLUTION;
                EFX_POPULATE_DWORD_2(timer_cmd,
                                     FRF_AB_TC_TIMER_MODE,
                                     FFE_BB_TIMER_MODE_INT_HLDOFF,
                                     FRF_AB_TC_TIMER_VAL,
-                                    channel->irq_moderation /
-                                    FALCON_IRQ_MOD_RESOLUTION - 1);
+                                    channel->irq_moderation - 1);
        } else {
                EFX_POPULATE_DWORD_2(timer_cmd,
                                     FRF_AB_TC_TIMER_MODE,
@@ -1417,13 +1394,13 @@ static irqreturn_t falcon_fatal_interrupt(struct efx_nic *efx)
        falcon_disable_interrupts(efx);
 
        /* Count errors and reset or disable the NIC accordingly */
-       if (nic_data->int_error_count == 0 ||
-           time_after(jiffies, nic_data->int_error_expire)) {
-               nic_data->int_error_count = 0;
-               nic_data->int_error_expire =
+       if (efx->int_error_count == 0 ||
+           time_after(jiffies, efx->int_error_expire)) {
+               efx->int_error_count = 0;
+               efx->int_error_expire =
                        jiffies + FALCON_INT_ERROR_EXPIRE * HZ;
        }
-       if (++nic_data->int_error_count < FALCON_MAX_INT_ERRORS) {
+       if (++efx->int_error_count < FALCON_MAX_INT_ERRORS) {
                EFX_ERR(efx, "SYSTEM ERROR - reset scheduled\n");
                efx_schedule_reset(efx, RESET_TYPE_INT_ERROR);
        } else {
@@ -2197,37 +2174,6 @@ static int falcon_mdio_read(struct net_device *net_dev,
        return rc;
 }
 
-static int falcon_probe_phy(struct efx_nic *efx)
-{
-       switch (efx->phy_type) {
-       case PHY_TYPE_SFX7101:
-               efx->phy_op = &falcon_sfx7101_phy_ops;
-               break;
-       case PHY_TYPE_SFT9001A:
-       case PHY_TYPE_SFT9001B:
-               efx->phy_op = &falcon_sft9001_phy_ops;
-               break;
-       case PHY_TYPE_QT2022C2:
-       case PHY_TYPE_QT2025C:
-               efx->phy_op = &falcon_xfp_phy_ops;
-               break;
-       default:
-               EFX_ERR(efx, "Unknown PHY type %d\n",
-                       efx->phy_type);
-               return -1;
-       }
-
-       if (efx->phy_op->macs & EFX_XMAC)
-               efx->loopback_modes |= ((1 << LOOPBACK_XGMII) |
-                                       (1 << LOOPBACK_XGXS) |
-                                       (1 << LOOPBACK_XAUI));
-       if (efx->phy_op->macs & EFX_GMAC)
-               efx->loopback_modes |= (1 << LOOPBACK_GMAC);
-       efx->loopback_modes |= efx->phy_op->loopbacks;
-
-       return 0;
-}
-
 int falcon_switch_mac(struct efx_nic *efx)
 {
        struct efx_mac_operations *old_mac_op = efx->mac_op;
@@ -2284,10 +2230,31 @@ int falcon_probe_port(struct efx_nic *efx)
 {
        int rc;
 
-       /* Hook in PHY operations table */
-       rc = falcon_probe_phy(efx);
-       if (rc)
-               return rc;
+       switch (efx->phy_type) {
+       case PHY_TYPE_SFX7101:
+               efx->phy_op = &falcon_sfx7101_phy_ops;
+               break;
+       case PHY_TYPE_SFT9001A:
+       case PHY_TYPE_SFT9001B:
+               efx->phy_op = &falcon_sft9001_phy_ops;
+               break;
+       case PHY_TYPE_QT2022C2:
+       case PHY_TYPE_QT2025C:
+               efx->phy_op = &falcon_qt202x_phy_ops;
+               break;
+       default:
+               EFX_ERR(efx, "Unknown PHY type %d\n",
+                       efx->phy_type);
+               return -ENODEV;
+       }
+
+       if (efx->phy_op->macs & EFX_XMAC)
+               efx->loopback_modes |= ((1 << LOOPBACK_XGMII) |
+                                       (1 << LOOPBACK_XGXS) |
+                                       (1 << LOOPBACK_XAUI));
+       if (efx->phy_op->macs & EFX_GMAC)
+               efx->loopback_modes |= (1 << LOOPBACK_GMAC);
+       efx->loopback_modes |= efx->phy_op->loopbacks;
 
        /* Set up MDIO structure for PHY */
        efx->mdio.mmds = efx->phy_op->mmds;
@@ -3141,23 +3108,19 @@ void falcon_update_nic_stats(struct efx_nic *efx)
  */
 
 struct efx_nic_type falcon_a_nic_type = {
-       .mem_bar = 2,
        .mem_map_size = 0x20000,
        .txd_ptr_tbl_base = FR_AA_TX_DESC_PTR_TBL_KER,
        .rxd_ptr_tbl_base = FR_AA_RX_DESC_PTR_TBL_KER,
        .buf_tbl_base = FR_AA_BUF_FULL_TBL_KER,
        .evq_ptr_tbl_base = FR_AA_EVQ_PTR_TBL_KER,
        .evq_rptr_tbl_base = FR_AA_EVQ_RPTR_KER,
-       .max_dma_mask = FALCON_DMA_MASK,
-       .tx_dma_mask = FALCON_TX_DMA_MASK,
-       .bug5391_mask = 0xf,
+       .max_dma_mask = DMA_BIT_MASK(FSF_AZ_TX_KER_BUF_ADDR_WIDTH),
        .rx_buffer_padding = 0x24,
        .max_interrupt_mode = EFX_INT_MODE_MSI,
        .phys_addr_channels = 4,
 };
 
 struct efx_nic_type falcon_b_nic_type = {
-       .mem_bar = 2,
        /* Map everything up to and including the RSS indirection
         * table.  Don't map MSI-X table, MSI-X PBA since Linux
         * requires that they not be mapped.  */
@@ -3169,9 +3132,7 @@ struct efx_nic_type falcon_b_nic_type = {
        .buf_tbl_base = FR_BZ_BUF_FULL_TBL,
        .evq_ptr_tbl_base = FR_BZ_EVQ_PTR_TBL,
        .evq_rptr_tbl_base = FR_BZ_EVQ_RPTR,
-       .max_dma_mask = FALCON_DMA_MASK,
-       .tx_dma_mask = FALCON_TX_DMA_MASK,
-       .bug5391_mask = 0,
+       .max_dma_mask = DMA_BIT_MASK(FSF_AZ_TX_KER_BUF_ADDR_WIDTH),
        .rx_buffer_padding = 0,
        .max_interrupt_mode = EFX_INT_MODE_MSIX,
        .phys_addr_channels = 32, /* Hardware limit is 64, but the legacy