~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to drivers/net/ixgbe/ixgbe_82598.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*******************************************************************************
2
2
 
3
3
  Intel 10 Gigabit PCI Express Linux driver
4
 
  Copyright(c) 1999 - 2010 Intel Corporation.
 
4
  Copyright(c) 1999 - 2011 Intel Corporation.
5
5
 
6
6
  This program is free software; you can redistribute it and/or modify it
7
7
  under the terms and conditions of the GNU General Public License,
37
37
#define IXGBE_82598_RAR_ENTRIES   16
38
38
#define IXGBE_82598_MC_TBL_SIZE  128
39
39
#define IXGBE_82598_VFT_TBL_SIZE 128
 
40
#define IXGBE_82598_RX_PB_SIZE   512
40
41
 
41
42
static s32 ixgbe_setup_copper_link_82598(struct ixgbe_hw *hw,
42
43
                                         ixgbe_link_speed speed,
158
159
 
159
160
        switch (hw->phy.type) {
160
161
        case ixgbe_phy_tn:
 
162
                phy->ops.setup_link = &ixgbe_setup_phy_link_tnx;
161
163
                phy->ops.check_link = &ixgbe_check_phy_link_tnx;
162
164
                phy->ops.get_firmware_version =
163
165
                             &ixgbe_get_phy_firmware_version_tnx;
196
198
 *  @hw: pointer to hardware structure
197
199
 *
198
200
 *  Starts the hardware using the generic start_hw function.
199
 
 *  Then set pcie completion timeout
 
201
 *  Disables relaxed ordering Then set pcie completion timeout
 
202
 *
200
203
 **/
201
204
static s32 ixgbe_start_hw_82598(struct ixgbe_hw *hw)
202
205
{
 
206
        u32 regval;
 
207
        u32 i;
203
208
        s32 ret_val = 0;
204
209
 
205
210
        ret_val = ixgbe_start_hw_generic(hw);
206
211
 
 
212
        /* Disable relaxed ordering */
 
213
        for (i = 0; ((i < hw->mac.max_tx_queues) &&
 
214
             (i < IXGBE_DCA_MAX_QUEUES_82598)); i++) {
 
215
                regval = IXGBE_READ_REG(hw, IXGBE_DCA_TXCTRL(i));
 
216
                regval &= ~IXGBE_DCA_TXCTRL_TX_WB_RO_EN;
 
217
                IXGBE_WRITE_REG(hw, IXGBE_DCA_TXCTRL(i), regval);
 
218
        }
 
219
 
 
220
        for (i = 0; ((i < hw->mac.max_rx_queues) &&
 
221
             (i < IXGBE_DCA_MAX_QUEUES_82598)); i++) {
 
222
                regval = IXGBE_READ_REG(hw, IXGBE_DCA_RXCTRL(i));
 
223
                regval &= ~(IXGBE_DCA_RXCTRL_DESC_WRO_EN |
 
224
                            IXGBE_DCA_RXCTRL_DESC_HSRO_EN);
 
225
                IXGBE_WRITE_REG(hw, IXGBE_DCA_RXCTRL(i), regval);
 
226
        }
 
227
 
 
228
        hw->mac.rx_pb_size = IXGBE_82598_RX_PB_SIZE;
 
229
 
207
230
        /* set the completion timeout for interface */
208
231
        if (ret_val == 0)
209
232
                ixgbe_set_pcie_completion_timeout(hw);
280
303
{
281
304
        enum ixgbe_media_type media_type;
282
305
 
 
306
        /* Detect if there is a copper PHY attached. */
 
307
        switch (hw->phy.type) {
 
308
        case ixgbe_phy_cu_unknown:
 
309
        case ixgbe_phy_tn:
 
310
        case ixgbe_phy_aq:
 
311
                media_type = ixgbe_media_type_copper;
 
312
                goto out;
 
313
        default:
 
314
                break;
 
315
        }
 
316
 
283
317
        /* Media type for I82598 is based on device ID */
284
318
        switch (hw->device_id) {
285
319
        case IXGBE_DEV_ID_82598:
286
320
        case IXGBE_DEV_ID_82598_BX:
 
321
                /* Default device ID is mezzanine card KX/KX4 */
287
322
                media_type = ixgbe_media_type_backplane;
288
323
                break;
289
324
        case IXGBE_DEV_ID_82598AF_DUAL_PORT:
306
341
                media_type = ixgbe_media_type_unknown;
307
342
                break;
308
343
        }
309
 
 
 
344
out:
310
345
        return media_type;
311
346
}
312
347
 
354
389
 
355
390
        /* Negotiate the fc mode to use */
356
391
        ret_val = ixgbe_fc_autoneg(hw);
357
 
        if (ret_val)
 
392
        if (ret_val == IXGBE_ERR_FLOW_CONTROL)
358
393
                goto out;
359
394
 
360
395
        /* Disable any previous flow control settings */
372
407
         * 2: Tx flow control is enabled (we can send pause frames but
373
408
         *     we do not support receiving pause frames).
374
409
         * 3: Both Rx and Tx flow control (symmetric) are enabled.
375
 
         * other: Invalid.
376
410
#ifdef CONFIG_DCB
377
411
         * 4: Priority Flow Control is enabled.
378
412
#endif
 
413
         * other: Invalid.
379
414
         */
380
415
        switch (hw->fc.current_mode) {
381
416
        case ixgbe_fc_none:
432
467
                reg = (rx_pba_size - hw->fc.low_water) << 6;
433
468
                if (hw->fc.send_xon)
434
469
                        reg |= IXGBE_FCRTL_XONE;
 
470
 
435
471
                IXGBE_WRITE_REG(hw, IXGBE_FCRTL(packetbuf_num), reg);
436
472
 
437
 
                reg = (rx_pba_size - hw->fc.high_water) << 10;
 
473
                reg = (rx_pba_size - hw->fc.high_water) << 6;
438
474
                reg |= IXGBE_FCRTH_FCEN;
439
475
 
440
476
                IXGBE_WRITE_REG(hw, IXGBE_FCRTH(packetbuf_num), reg);
627
663
        return 0;
628
664
}
629
665
 
630
 
 
631
666
/**
632
667
 *  ixgbe_setup_mac_link_82598 - Set MAC link speed
633
668
 *  @hw: pointer to hardware structure
634
669
 *  @speed: new link speed
635
670
 *  @autoneg: true if auto-negotiation enabled
636
 
 *  @autoneg_wait_to_complete: true if waiting is needed to complete
 
671
 *  @autoneg_wait_to_complete: true when waiting for completion is needed
637
672
 *
638
673
 *  Set the link speed in the AUTOC register and restarts link.
639
674
 **/
672
707
                 * ixgbe_hw This will write the AUTOC register based on the new
673
708
                 * stored values
674
709
                 */
675
 
                status = ixgbe_start_mac_link_82598(hw, autoneg_wait_to_complete);
 
710
                status = ixgbe_start_mac_link_82598(hw,
 
711
                                                    autoneg_wait_to_complete);
676
712
        }
677
713
 
678
714
        return status;
698
734
        /* Setup the PHY according to input speed */
699
735
        status = hw->phy.ops.setup_link_speed(hw, speed, autoneg,
700
736
                                              autoneg_wait_to_complete);
701
 
 
702
737
        /* Set up MAC */
703
738
        ixgbe_start_mac_link_82598(hw, autoneg_wait_to_complete);
704
739
 
770
805
                else if (phy_status == IXGBE_ERR_SFP_NOT_PRESENT)
771
806
                        goto no_phy_reset;
772
807
 
773
 
 
774
808
                hw->phy.ops.reset(hw);
775
809
        }
776
810
 
779
813
         * Prevent the PCI-E bus from from hanging by disabling PCI-E master
780
814
         * access and verify no pending requests before reset
781
815
         */
782
 
        status = ixgbe_disable_pcie_master(hw);
783
 
        if (status != 0) {
784
 
                status = IXGBE_ERR_MASTER_REQUESTS_PENDING;
785
 
                hw_dbg(hw, "PCI-E Master disable polling has failed.\n");
786
 
        }
 
816
        ixgbe_disable_pcie_master(hw);
787
817
 
 
818
mac_reset_top:
788
819
        /*
789
820
         * Issue global reset to the MAC.  This needs to be a SW reset.
790
821
         * If link reset is used, it might reset the MAC when mng is using it
805
836
                hw_dbg(hw, "Reset polling failed to complete.\n");
806
837
        }
807
838
 
 
839
        /*
 
840
         * Double resets are required for recovery from certain error
 
841
         * conditions.  Between resets, it is necessary to stall to allow time
 
842
         * for any pending HW events to complete.  We use 1usec since that is
 
843
         * what is needed for ixgbe_disable_pcie_master().  The second reset
 
844
         * then clears out any effects of those events.
 
845
         */
 
846
        if (hw->mac.flags & IXGBE_FLAGS_DOUBLE_RESET_REQUIRED) {
 
847
                hw->mac.flags &= ~IXGBE_FLAGS_DOUBLE_RESET_REQUIRED;
 
848
                udelay(1);
 
849
                goto mac_reset_top;
 
850
        }
 
851
 
808
852
        msleep(50);
809
853
 
810
854
        gheccr = IXGBE_READ_REG(hw, IXGBE_GHECCR);
824
868
                IXGBE_WRITE_REG(hw, IXGBE_AUTOC, hw->mac.orig_autoc);
825
869
        }
826
870
 
 
871
        /* Store the permanent mac address */
 
872
        hw->mac.ops.get_mac_addr(hw, hw->mac.perm_addr);
 
873
 
827
874
        /*
828
875
         * Store MAC address from RAR0, clear receive address registers, and
829
876
         * clear the multicast table
830
877
         */
831
878
        hw->mac.ops.init_rx_addrs(hw);
832
879
 
833
 
        /* Store the permanent mac address */
834
 
        hw->mac.ops.get_mac_addr(hw, hw->mac.perm_addr);
835
 
 
836
880
reset_hw_out:
837
881
        if (phy_status)
838
882
                status = phy_status;
849
893
static s32 ixgbe_set_vmdq_82598(struct ixgbe_hw *hw, u32 rar, u32 vmdq)
850
894
{
851
895
        u32 rar_high;
 
896
        u32 rar_entries = hw->mac.num_rar_entries;
 
897
 
 
898
        /* Make sure we are using a valid rar index range */
 
899
        if (rar >= rar_entries) {
 
900
                hw_dbg(hw, "RAR index %d is out of range.\n", rar);
 
901
                return IXGBE_ERR_INVALID_ARGUMENT;
 
902
        }
852
903
 
853
904
        rar_high = IXGBE_READ_REG(hw, IXGBE_RAH(rar));
854
905
        rar_high &= ~IXGBE_RAH_VIND_MASK;
868
919
        u32 rar_high;
869
920
        u32 rar_entries = hw->mac.num_rar_entries;
870
921
 
871
 
        if (rar < rar_entries) {
872
 
                rar_high = IXGBE_READ_REG(hw, IXGBE_RAH(rar));
873
 
                if (rar_high & IXGBE_RAH_VIND_MASK) {
874
 
                        rar_high &= ~IXGBE_RAH_VIND_MASK;
875
 
                        IXGBE_WRITE_REG(hw, IXGBE_RAH(rar), rar_high);
876
 
                }
877
 
        } else {
 
922
 
 
923
        /* Make sure we are using a valid rar index range */
 
924
        if (rar >= rar_entries) {
878
925
                hw_dbg(hw, "RAR index %d is out of range.\n", rar);
 
926
                return IXGBE_ERR_INVALID_ARGUMENT;
 
927
        }
 
928
 
 
929
        rar_high = IXGBE_READ_REG(hw, IXGBE_RAH(rar));
 
930
        if (rar_high & IXGBE_RAH_VIND_MASK) {
 
931
                rar_high &= ~IXGBE_RAH_VIND_MASK;
 
932
                IXGBE_WRITE_REG(hw, IXGBE_RAH(rar), rar_high);
879
933
        }
880
934
 
881
935
        return 0;
994
1048
}
995
1049
 
996
1050
/**
997
 
 *  ixgbe_read_i2c_eeprom_82598 - Read 8 bit EEPROM word of an SFP+ module
998
 
 *  over I2C interface through an intermediate phy.
 
1051
 *  ixgbe_read_i2c_eeprom_82598 - Reads 8 bit word over I2C interface.
999
1052
 *  @hw: pointer to hardware structure
1000
1053
 *  @byte_offset: EEPROM byte offset to read
1001
1054
 *  @eeprom_data: value read
1002
1055
 *
1003
 
 *  Performs byte read operation to SFP module's EEPROM over I2C interface.
 
1056
 *  Performs 8 byte read operation to SFP module's EEPROM over I2C interface.
1004
1057
 **/
1005
1058
static s32 ixgbe_read_i2c_eeprom_82598(struct ixgbe_hw *hw, u8 byte_offset,
1006
1059
                                       u8 *eeprom_data)
1033
1086
                        sfp_stat = sfp_stat & IXGBE_I2C_EEPROM_STATUS_MASK;
1034
1087
                        if (sfp_stat != IXGBE_I2C_EEPROM_STATUS_IN_PROGRESS)
1035
1088
                                break;
1036
 
                        msleep(10);
 
1089
                        usleep_range(10000, 20000);
1037
1090
                }
1038
1091
 
1039
1092
                if (sfp_stat != IXGBE_I2C_EEPROM_STATUS_PASS) {
1074
1127
 
1075
1128
        /* Copper PHY must be checked before AUTOC LMS to determine correct
1076
1129
         * physical layer because 10GBase-T PHYs use LMS = KX4/KX */
1077
 
        if (hw->phy.type == ixgbe_phy_tn ||
1078
 
            hw->phy.type == ixgbe_phy_cu_unknown) {
1079
 
                hw->phy.ops.read_reg(hw, MDIO_PMA_EXTABLE, MDIO_MMD_PMAPMD,
1080
 
                                     &ext_ability);
 
1130
        switch (hw->phy.type) {
 
1131
        case ixgbe_phy_tn:
 
1132
        case ixgbe_phy_aq:
 
1133
        case ixgbe_phy_cu_unknown:
 
1134
                hw->phy.ops.read_reg(hw, MDIO_PMA_EXTABLE,
 
1135
                MDIO_MMD_PMAPMD, &ext_ability);
1081
1136
                if (ext_ability & MDIO_PMA_EXTABLE_10GBT)
1082
1137
                        physical_layer |= IXGBE_PHYSICAL_LAYER_10GBASE_T;
1083
1138
                if (ext_ability & MDIO_PMA_EXTABLE_1000BT)
1085
1140
                if (ext_ability & MDIO_PMA_EXTABLE_100BTX)
1086
1141
                        physical_layer |= IXGBE_PHYSICAL_LAYER_100BASE_TX;
1087
1142
                goto out;
 
1143
        default:
 
1144
                break;
1088
1145
        }
1089
1146
 
1090
1147
        switch (autoc & IXGBE_AUTOC_LMS_MASK) {
1153
1210
        return physical_layer;
1154
1211
}
1155
1212
 
 
1213
/**
 
1214
 *  ixgbe_set_lan_id_multi_port_pcie_82598 - Set LAN id for PCIe multiple
 
1215
 *  port devices.
 
1216
 *  @hw: pointer to the HW structure
 
1217
 *
 
1218
 *  Calls common function and corrects issue with some single port devices
 
1219
 *  that enable LAN1 but not LAN0.
 
1220
 **/
 
1221
static void ixgbe_set_lan_id_multi_port_pcie_82598(struct ixgbe_hw *hw)
 
1222
{
 
1223
        struct ixgbe_bus_info *bus = &hw->bus;
 
1224
        u16 pci_gen = 0;
 
1225
        u16 pci_ctrl2 = 0;
 
1226
 
 
1227
        ixgbe_set_lan_id_multi_port_pcie(hw);
 
1228
 
 
1229
        /* check if LAN0 is disabled */
 
1230
        hw->eeprom.ops.read(hw, IXGBE_PCIE_GENERAL_PTR, &pci_gen);
 
1231
        if ((pci_gen != 0) && (pci_gen != 0xFFFF)) {
 
1232
 
 
1233
                hw->eeprom.ops.read(hw, pci_gen + IXGBE_PCIE_CTRL2, &pci_ctrl2);
 
1234
 
 
1235
                /* if LAN0 is completely disabled force function to 0 */
 
1236
                if ((pci_ctrl2 & IXGBE_PCIE_CTRL2_LAN_DISABLE) &&
 
1237
                    !(pci_ctrl2 & IXGBE_PCIE_CTRL2_DISABLE_SELECT) &&
 
1238
                    !(pci_ctrl2 & IXGBE_PCIE_CTRL2_DUMMY_ENABLE)) {
 
1239
 
 
1240
                        bus->func = 0;
 
1241
                }
 
1242
        }
 
1243
}
 
1244
 
1156
1245
static struct ixgbe_mac_operations mac_ops_82598 = {
1157
1246
        .init_hw                = &ixgbe_init_hw_generic,
1158
1247
        .reset_hw               = &ixgbe_reset_hw_82598,
1164
1253
        .get_mac_addr           = &ixgbe_get_mac_addr_generic,
1165
1254
        .stop_adapter           = &ixgbe_stop_adapter_generic,
1166
1255
        .get_bus_info           = &ixgbe_get_bus_info_generic,
1167
 
        .set_lan_id             = &ixgbe_set_lan_id_multi_port_pcie,
 
1256
        .set_lan_id             = &ixgbe_set_lan_id_multi_port_pcie_82598,
1168
1257
        .read_analog_reg8       = &ixgbe_read_analog_reg8_82598,
1169
1258
        .write_analog_reg8      = &ixgbe_write_analog_reg8_82598,
1170
1259
        .setup_link             = &ixgbe_setup_mac_link_82598,
1179
1268
        .set_vmdq               = &ixgbe_set_vmdq_82598,
1180
1269
        .clear_vmdq             = &ixgbe_clear_vmdq_82598,
1181
1270
        .init_rx_addrs          = &ixgbe_init_rx_addrs_generic,
1182
 
        .update_uc_addr_list    = &ixgbe_update_uc_addr_list_generic,
1183
1271
        .update_mc_addr_list    = &ixgbe_update_mc_addr_list_generic,
1184
1272
        .enable_mc              = &ixgbe_enable_mc_generic,
1185
1273
        .disable_mc             = &ixgbe_disable_mc_generic,
1186
1274
        .clear_vfta             = &ixgbe_clear_vfta_82598,
1187
1275
        .set_vfta               = &ixgbe_set_vfta_82598,
1188
1276
        .fc_enable              = &ixgbe_fc_enable_82598,
 
1277
        .acquire_swfw_sync      = &ixgbe_acquire_swfw_sync,
 
1278
        .release_swfw_sync      = &ixgbe_release_swfw_sync,
1189
1279
};
1190
1280
 
1191
1281
static struct ixgbe_eeprom_operations eeprom_ops_82598 = {
1192
1282
        .init_params            = &ixgbe_init_eeprom_params_generic,
1193
1283
        .read                   = &ixgbe_read_eerd_generic,
 
1284
        .read_buffer            = &ixgbe_read_eerd_buffer_generic,
1194
1285
        .calc_checksum          = &ixgbe_calc_eeprom_checksum_generic,
1195
1286
        .validate_checksum      = &ixgbe_validate_eeprom_checksum_generic,
1196
1287
        .update_checksum        = &ixgbe_update_eeprom_checksum_generic,