]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - drivers/net/bnx2x/bnx2x_link.c
Merge tag 'v2.6.38' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[mv-sheeva.git] / drivers / net / bnx2x / bnx2x_link.c
index 580919619252e3d0594f5365226bc295a8efcba9..dd1210fddfffafec1ef3c1b8ca13344715be4f7f 100644 (file)
 #define EDC_MODE_PASSIVE_DAC                   0x0055
 
 
-
+#define ETS_BW_LIMIT_CREDIT_UPPER_BOUND                (0x5000)
+#define ETS_BW_LIMIT_CREDIT_WEIGHT             (0x5000)
 /**********************************************************/
 /*                     INTERFACE                          */
 /**********************************************************/
@@ -205,6 +206,270 @@ static u32 bnx2x_bits_dis(struct bnx2x *bp, u32 reg, u32 bits)
        return val;
 }
 
+/******************************************************************/
+/*                             ETS section                       */
+/******************************************************************/
+void bnx2x_ets_disabled(struct link_params *params)
+{
+       /* ETS disabled configuration*/
+       struct bnx2x *bp = params->bp;
+
+       DP(NETIF_MSG_LINK, "ETS disabled configuration\n");
+
+       /**
+        * mapping between entry  priority to client number (0,1,2 -debug and
+        * management clients, 3 - COS0 client, 4 - COS client)(HIGHEST)
+        * 3bits client num.
+        *   PRI4    |    PRI3    |    PRI2    |    PRI1    |    PRI0
+        * cos1-100     cos0-011     dbg1-010     dbg0-001     MCP-000
+        */
+
+       REG_WR(bp, NIG_REG_P0_TX_ARB_PRIORITY_CLIENT, 0x4688);
+       /**
+        * Bitmap of 5bits length. Each bit specifies whether the entry behaves
+        * as strict.  Bits 0,1,2 - debug and management entries, 3 -
+        * COS0 entry, 4 - COS1 entry.
+        * COS1 | COS0 | DEBUG1 | DEBUG0 | MGMT
+        * bit4   bit3    bit2   bit1     bit0
+        * MCP and debug are strict
+        */
+
+       REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_IS_STRICT, 0x7);
+       /* defines which entries (clients) are subjected to WFQ arbitration */
+       REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_IS_SUBJECT2WFQ, 0);
+       /**
+       * For strict priority entries defines the number of consecutive
+       * slots for the highest priority.
+       */
+       REG_WR(bp, NIG_REG_P0_TX_ARB_NUM_STRICT_ARB_SLOTS, 0x100);
+       /**
+        * mapping between the CREDIT_WEIGHT registers and actual client
+        * numbers
+        */
+       REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_CREDIT_MAP, 0);
+       REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_0, 0);
+       REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_1, 0);
+
+       REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_0, 0);
+       REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_1, 0);
+       REG_WR(bp, PBF_REG_HIGH_PRIORITY_COS_NUM, 0);
+       /* ETS mode disable */
+       REG_WR(bp, PBF_REG_ETS_ENABLED, 0);
+       /**
+        * If ETS mode is enabled (there is no strict priority) defines a WFQ
+        * weight for COS0/COS1.
+        */
+       REG_WR(bp, PBF_REG_COS0_WEIGHT, 0x2710);
+       REG_WR(bp, PBF_REG_COS1_WEIGHT, 0x2710);
+       /* Upper bound that COS0_WEIGHT can reach in the WFQ arbiter */
+       REG_WR(bp, PBF_REG_COS0_UPPER_BOUND, 0x989680);
+       REG_WR(bp, PBF_REG_COS1_UPPER_BOUND, 0x989680);
+       /* Defines the number of consecutive slots for the strict priority */
+       REG_WR(bp, PBF_REG_NUM_STRICT_ARB_SLOTS, 0);
+}
+
+void bnx2x_ets_bw_limit_common(const struct link_params *params)
+{
+       /* ETS disabled configuration */
+       struct bnx2x *bp = params->bp;
+       DP(NETIF_MSG_LINK, "ETS enabled BW limit configuration\n");
+       /**
+       * defines which entries (clients) are subjected to WFQ arbitration
+       * COS0 0x8
+       * COS1 0x10
+       */
+       REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_IS_SUBJECT2WFQ, 0x18);
+       /**
+       * mapping between the ARB_CREDIT_WEIGHT registers and actual
+       * client numbers (WEIGHT_0 does not actually have to represent
+       * client 0)
+       *    PRI4    |    PRI3    |    PRI2    |    PRI1    |    PRI0
+       *  cos1-001     cos0-000     dbg1-100     dbg0-011     MCP-010
+       */
+       REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_CREDIT_MAP, 0x111A);
+
+       REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_0,
+              ETS_BW_LIMIT_CREDIT_UPPER_BOUND);
+       REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_UPPER_BOUND_1,
+              ETS_BW_LIMIT_CREDIT_UPPER_BOUND);
+
+       /* ETS mode enabled*/
+       REG_WR(bp, PBF_REG_ETS_ENABLED, 1);
+
+       /* Defines the number of consecutive slots for the strict priority */
+       REG_WR(bp, PBF_REG_NUM_STRICT_ARB_SLOTS, 0);
+       /**
+       * Bitmap of 5bits length. Each bit specifies whether the entry behaves
+       * as strict.  Bits 0,1,2 - debug and management entries, 3 - COS0
+       * entry, 4 - COS1 entry.
+       * COS1 | COS0 | DEBUG21 | DEBUG0 | MGMT
+       * bit4   bit3     bit2     bit1    bit0
+       * MCP and debug are strict
+       */
+       REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_IS_STRICT, 0x7);
+
+       /* Upper bound that COS0_WEIGHT can reach in the WFQ arbiter.*/
+       REG_WR(bp, PBF_REG_COS0_UPPER_BOUND,
+              ETS_BW_LIMIT_CREDIT_UPPER_BOUND);
+       REG_WR(bp, PBF_REG_COS1_UPPER_BOUND,
+              ETS_BW_LIMIT_CREDIT_UPPER_BOUND);
+}
+
+void bnx2x_ets_bw_limit(const struct link_params *params, const u32 cos0_bw,
+                       const u32 cos1_bw)
+{
+       /* ETS disabled configuration*/
+       struct bnx2x *bp = params->bp;
+       const u32 total_bw = cos0_bw + cos1_bw;
+       u32 cos0_credit_weight = 0;
+       u32 cos1_credit_weight = 0;
+
+       DP(NETIF_MSG_LINK, "ETS enabled BW limit configuration\n");
+
+       if ((0 == total_bw) ||
+           (0 == cos0_bw) ||
+           (0 == cos1_bw)) {
+               DP(NETIF_MSG_LINK,
+                  "bnx2x_ets_bw_limit: Total BW can't be zero\n");
+               return;
+       }
+
+       cos0_credit_weight = (cos0_bw * ETS_BW_LIMIT_CREDIT_WEIGHT)/
+               total_bw;
+       cos1_credit_weight = (cos1_bw * ETS_BW_LIMIT_CREDIT_WEIGHT)/
+               total_bw;
+
+       bnx2x_ets_bw_limit_common(params);
+
+       REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_0, cos0_credit_weight);
+       REG_WR(bp, NIG_REG_P0_TX_ARB_CREDIT_WEIGHT_1, cos1_credit_weight);
+
+       REG_WR(bp, PBF_REG_COS0_WEIGHT, cos0_credit_weight);
+       REG_WR(bp, PBF_REG_COS1_WEIGHT, cos1_credit_weight);
+}
+
+u8 bnx2x_ets_strict(const struct link_params *params, const u8 strict_cos)
+{
+       /* ETS disabled configuration*/
+       struct bnx2x *bp = params->bp;
+       u32 val = 0;
+
+       DP(NETIF_MSG_LINK, "ETS enabled strict configuration\n");
+       /**
+        * Bitmap of 5bits length. Each bit specifies whether the entry behaves
+        * as strict.  Bits 0,1,2 - debug and management entries,
+        * 3 - COS0 entry, 4 - COS1 entry.
+        *  COS1 | COS0 | DEBUG21 | DEBUG0 | MGMT
+        *  bit4   bit3   bit2      bit1     bit0
+        * MCP and debug are strict
+        */
+       REG_WR(bp, NIG_REG_P0_TX_ARB_CLIENT_IS_STRICT, 0x1F);
+       /**
+        * For strict priority entries defines the number of consecutive slots
+        * for the highest priority.
+        */
+       REG_WR(bp, NIG_REG_P0_TX_ARB_NUM_STRICT_ARB_SLOTS, 0x100);
+       /* ETS mode disable */
+       REG_WR(bp, PBF_REG_ETS_ENABLED, 0);
+       /* Defines the number of consecutive slots for the strict priority */
+       REG_WR(bp, PBF_REG_NUM_STRICT_ARB_SLOTS, 0x100);
+
+       /* Defines the number of consecutive slots for the strict priority */
+       REG_WR(bp, PBF_REG_HIGH_PRIORITY_COS_NUM, strict_cos);
+
+       /**
+       * mapping between entry  priority to client number (0,1,2 -debug and
+       * management clients, 3 - COS0 client, 4 - COS client)(HIGHEST)
+       * 3bits client num.
+       *   PRI4    |    PRI3    |    PRI2    |    PRI1    |    PRI0
+       * dbg0-010     dbg1-001     cos1-100     cos0-011     MCP-000
+       * dbg0-010     dbg1-001     cos0-011     cos1-100     MCP-000
+       */
+       val = (0 == strict_cos) ? 0x2318 : 0x22E0;
+       REG_WR(bp, NIG_REG_P0_TX_ARB_PRIORITY_CLIENT, val);
+
+       return 0;
+}
+/******************************************************************/
+/*                     ETS section                               */
+/******************************************************************/
+
+static void bnx2x_bmac2_get_pfc_stat(struct link_params *params,
+                                    u32 pfc_frames_sent[2],
+                                    u32 pfc_frames_received[2])
+{
+       /* Read pfc statistic */
+       struct bnx2x *bp = params->bp;
+       u32 bmac_addr = params->port ? NIG_REG_INGRESS_BMAC1_MEM :
+               NIG_REG_INGRESS_BMAC0_MEM;
+
+       DP(NETIF_MSG_LINK, "pfc statistic read from BMAC\n");
+
+       REG_RD_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_TX_STAT_GTPP,
+                                       pfc_frames_sent, 2);
+
+       REG_RD_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_RX_STAT_GRPP,
+                                       pfc_frames_received, 2);
+
+}
+static void bnx2x_emac_get_pfc_stat(struct link_params *params,
+                                   u32 pfc_frames_sent[2],
+                                   u32 pfc_frames_received[2])
+{
+       /* Read pfc statistic */
+       struct bnx2x *bp = params->bp;
+       u32 emac_base = params->port ? GRCBASE_EMAC1 : GRCBASE_EMAC0;
+       u32 val_xon = 0;
+       u32 val_xoff = 0;
+
+       DP(NETIF_MSG_LINK, "pfc statistic read from EMAC\n");
+
+       /* PFC received frames */
+       val_xoff = REG_RD(bp, emac_base +
+                               EMAC_REG_RX_PFC_STATS_XOFF_RCVD);
+       val_xoff &= EMAC_REG_RX_PFC_STATS_XOFF_RCVD_COUNT;
+       val_xon = REG_RD(bp, emac_base + EMAC_REG_RX_PFC_STATS_XON_RCVD);
+       val_xon &= EMAC_REG_RX_PFC_STATS_XON_RCVD_COUNT;
+
+       pfc_frames_received[0] = val_xon + val_xoff;
+
+       /* PFC received sent */
+       val_xoff = REG_RD(bp, emac_base +
+                               EMAC_REG_RX_PFC_STATS_XOFF_SENT);
+       val_xoff &= EMAC_REG_RX_PFC_STATS_XOFF_SENT_COUNT;
+       val_xon = REG_RD(bp, emac_base + EMAC_REG_RX_PFC_STATS_XON_SENT);
+       val_xon &= EMAC_REG_RX_PFC_STATS_XON_SENT_COUNT;
+
+       pfc_frames_sent[0] = val_xon + val_xoff;
+}
+
+void bnx2x_pfc_statistic(struct link_params *params, struct link_vars *vars,
+                        u32 pfc_frames_sent[2],
+                        u32 pfc_frames_received[2])
+{
+       /* Read pfc statistic */
+       struct bnx2x *bp = params->bp;
+       u32 val = 0;
+       DP(NETIF_MSG_LINK, "pfc statistic\n");
+
+       if (!vars->link_up)
+               return;
+
+       val = REG_RD(bp, MISC_REG_RESET_REG_2);
+       if ((val & (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << params->port))
+           == 0) {
+               DP(NETIF_MSG_LINK, "About to read stats from EMAC\n");
+               bnx2x_emac_get_pfc_stat(params, pfc_frames_sent,
+                                       pfc_frames_received);
+       } else {
+               DP(NETIF_MSG_LINK, "About to read stats from BMAC\n");
+               bnx2x_bmac2_get_pfc_stat(params, pfc_frames_sent,
+                                        pfc_frames_received);
+       }
+}
+/******************************************************************/
+/*                     MAC/PBF section                           */
+/******************************************************************/
 static void bnx2x_emac_init(struct link_params *params,
                           struct link_vars *vars)
 {
@@ -315,24 +580,55 @@ static u8 bnx2x_emac_enable(struct link_params *params,
                /* pause enable/disable */
                bnx2x_bits_dis(bp, emac_base + EMAC_REG_EMAC_RX_MODE,
                               EMAC_RX_MODE_FLOW_EN);
-               if (vars->flow_ctrl & BNX2X_FLOW_CTRL_RX)
-                       bnx2x_bits_en(bp, emac_base +
-                                   EMAC_REG_EMAC_RX_MODE,
-                                   EMAC_RX_MODE_FLOW_EN);
 
                bnx2x_bits_dis(bp,  emac_base + EMAC_REG_EMAC_TX_MODE,
-                            (EMAC_TX_MODE_EXT_PAUSE_EN |
-                             EMAC_TX_MODE_FLOW_EN));
-               if (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX)
-                       bnx2x_bits_en(bp, emac_base +
-                                   EMAC_REG_EMAC_TX_MODE,
-                                  (EMAC_TX_MODE_EXT_PAUSE_EN |
-                                   EMAC_TX_MODE_FLOW_EN));
+                              (EMAC_TX_MODE_EXT_PAUSE_EN |
+                               EMAC_TX_MODE_FLOW_EN));
+               if (!(params->feature_config_flags &
+                     FEATURE_CONFIG_PFC_ENABLED)) {
+                       if (vars->flow_ctrl & BNX2X_FLOW_CTRL_RX)
+                               bnx2x_bits_en(bp, emac_base +
+                                             EMAC_REG_EMAC_RX_MODE,
+                                             EMAC_RX_MODE_FLOW_EN);
+
+                       if (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX)
+                               bnx2x_bits_en(bp, emac_base +
+                                             EMAC_REG_EMAC_TX_MODE,
+                                             (EMAC_TX_MODE_EXT_PAUSE_EN |
+                                              EMAC_TX_MODE_FLOW_EN));
+               } else
+                       bnx2x_bits_en(bp, emac_base + EMAC_REG_EMAC_TX_MODE,
+                                     EMAC_TX_MODE_FLOW_EN);
        }
 
        /* KEEP_VLAN_TAG, promiscuous */
        val = REG_RD(bp, emac_base + EMAC_REG_EMAC_RX_MODE);
        val |= EMAC_RX_MODE_KEEP_VLAN_TAG | EMAC_RX_MODE_PROMISCUOUS;
+
+       /**
+       * Setting this bit causes MAC control frames (except for pause
+       * frames) to be passed on for processing. This setting has no
+       * affect on the operation of the pause frames. This bit effects
+       * all packets regardless of RX Parser packet sorting logic.
+       * Turn the PFC off to make sure we are in Xon state before
+       * enabling it.
+       */
+       EMAC_WR(bp, EMAC_REG_RX_PFC_MODE, 0);
+       if (params->feature_config_flags & FEATURE_CONFIG_PFC_ENABLED) {
+               DP(NETIF_MSG_LINK, "PFC is enabled\n");
+               /* Enable PFC again */
+               EMAC_WR(bp, EMAC_REG_RX_PFC_MODE,
+                       EMAC_REG_RX_PFC_MODE_RX_EN |
+                       EMAC_REG_RX_PFC_MODE_TX_EN |
+                       EMAC_REG_RX_PFC_MODE_PRIORITIES);
+
+               EMAC_WR(bp, EMAC_REG_RX_PFC_PARAM,
+                       ((0x0101 <<
+                         EMAC_REG_RX_PFC_PARAM_OPCODE_BITSHIFT) |
+                        (0x00ff <<
+                         EMAC_REG_RX_PFC_PARAM_PRIORITY_EN_BITSHIFT)));
+               val |= EMAC_RX_MODE_KEEP_MAC_CONTROL;
+       }
        EMAC_WR(bp, EMAC_REG_EMAC_RX_MODE, val);
 
        /* Set Loopback */
@@ -362,7 +658,9 @@ static u8 bnx2x_emac_enable(struct link_params *params,
        /* enable the NIG in/out to the emac */
        REG_WR(bp, NIG_REG_EMAC0_IN_EN + port*4, 0x1);
        val = 0;
-       if (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX)
+       if ((params->feature_config_flags &
+             FEATURE_CONFIG_PFC_ENABLED) ||
+           (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX))
                val = 1;
 
        REG_WR(bp, NIG_REG_EMAC0_PAUSE_OUT_EN + port*4, val);
@@ -383,9 +681,38 @@ static u8 bnx2x_emac_enable(struct link_params *params,
        return 0;
 }
 
-static void bnx2x_update_bmac2(struct link_params *params,
-                              struct link_vars *vars,
-                              u8 is_lb)
+static void bnx2x_update_pfc_bmac1(struct link_params *params,
+                                  struct link_vars *vars)
+{
+       u32 wb_data[2];
+       struct bnx2x *bp = params->bp;
+       u32 bmac_addr =  params->port ? NIG_REG_INGRESS_BMAC1_MEM :
+               NIG_REG_INGRESS_BMAC0_MEM;
+
+       u32 val = 0x14;
+       if ((!(params->feature_config_flags &
+             FEATURE_CONFIG_PFC_ENABLED)) &&
+               (vars->flow_ctrl & BNX2X_FLOW_CTRL_RX))
+               /* Enable BigMAC to react on received Pause packets */
+               val |= (1<<5);
+       wb_data[0] = val;
+       wb_data[1] = 0;
+       REG_WR_DMAE(bp, bmac_addr + BIGMAC_REGISTER_RX_CONTROL, wb_data, 2);
+
+       /* tx control */
+       val = 0xc0;
+       if (!(params->feature_config_flags &
+             FEATURE_CONFIG_PFC_ENABLED) &&
+               (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX))
+               val |= 0x800000;
+       wb_data[0] = val;
+       wb_data[1] = 0;
+       REG_WR_DMAE(bp, bmac_addr + BIGMAC_REGISTER_TX_CONTROL, wb_data, 2);
+}
+
+static void bnx2x_update_pfc_bmac2(struct link_params *params,
+                                  struct link_vars *vars,
+                                  u8 is_lb)
 {
        /*
         * Set rx control: Strip CRC and enable BigMAC to relay
@@ -397,7 +724,9 @@ static void bnx2x_update_bmac2(struct link_params *params,
                NIG_REG_INGRESS_BMAC0_MEM;
        u32 val = 0x14;
 
-       if (vars->flow_ctrl & BNX2X_FLOW_CTRL_RX)
+       if ((!(params->feature_config_flags &
+             FEATURE_CONFIG_PFC_ENABLED)) &&
+               (vars->flow_ctrl & BNX2X_FLOW_CTRL_RX))
                /* Enable BigMAC to react on received Pause packets */
                val |= (1<<5);
        wb_data[0] = val;
@@ -408,14 +737,47 @@ static void bnx2x_update_bmac2(struct link_params *params,
 
        /* Tx control */
        val = 0xc0;
-       if (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX)
+       if (!(params->feature_config_flags &
+                               FEATURE_CONFIG_PFC_ENABLED) &&
+           (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX))
                val |= 0x800000;
        wb_data[0] = val;
        wb_data[1] = 0;
-       REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_TX_CONTROL,
-                       wb_data, 2);
+       REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_TX_CONTROL, wb_data, 2);
+
+       if (params->feature_config_flags & FEATURE_CONFIG_PFC_ENABLED) {
+               DP(NETIF_MSG_LINK, "PFC is enabled\n");
+               /* Enable PFC RX & TX & STATS and set 8 COS  */
+               wb_data[0] = 0x0;
+               wb_data[0] |= (1<<0);  /* RX */
+               wb_data[0] |= (1<<1);  /* TX */
+               wb_data[0] |= (1<<2);  /* Force initial Xon */
+               wb_data[0] |= (1<<3);  /* 8 cos */
+               wb_data[0] |= (1<<5);  /* STATS */
+               wb_data[1] = 0;
+               REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_PFC_CONTROL,
+                           wb_data, 2);
+               /* Clear the force Xon */
+               wb_data[0] &= ~(1<<2);
+       } else {
+               DP(NETIF_MSG_LINK, "PFC is disabled\n");
+               /* disable PFC RX & TX & STATS and set 8 COS */
+               wb_data[0] = 0x8;
+               wb_data[1] = 0;
+       }
 
+       REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_PFC_CONTROL, wb_data, 2);
+
+       /**
+       * Set Time (based unit is 512 bit time) between automatic
+       * re-sending of PP packets amd enable automatic re-send of
+       * Per-Priroity Packet as long as pp_gen is asserted and
+       * pp_disable is low.
+       */
        val = 0x8000;
+       if (params->feature_config_flags & FEATURE_CONFIG_PFC_ENABLED)
+               val |= (1<<16); /* enable automatic re-send */
+
        wb_data[0] = val;
        wb_data[1] = 0;
        REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_TX_PAUSE_CONTROL,
@@ -427,6 +789,9 @@ static void bnx2x_update_bmac2(struct link_params *params,
                val |= 0x4; /* Local loopback */
                DP(NETIF_MSG_LINK, "enable bmac loopback\n");
        }
+       /* When PFC enabled, Pass pause frames towards the NIG. */
+       if (params->feature_config_flags & FEATURE_CONFIG_PFC_ENABLED)
+               val |= ((1<<6)|(1<<5));
 
        wb_data[0] = val;
        wb_data[1] = 0;
@@ -434,6 +799,239 @@ static void bnx2x_update_bmac2(struct link_params *params,
                        wb_data, 2);
 }
 
+static void bnx2x_update_pfc_brb(struct link_params *params,
+               struct link_vars *vars,
+               struct bnx2x_nig_brb_pfc_port_params *pfc_params)
+{
+       struct bnx2x *bp = params->bp;
+       int set_pfc = params->feature_config_flags &
+               FEATURE_CONFIG_PFC_ENABLED;
+
+       /* default - pause configuration */
+       u32 pause_xoff_th = PFC_BRB_MAC_PAUSE_XOFF_THRESHOLD_PAUSEABLE;
+       u32 pause_xon_th = PFC_BRB_MAC_PAUSE_XON_THRESHOLD_PAUSEABLE;
+       u32 full_xoff_th = PFC_BRB_MAC_FULL_XOFF_THRESHOLD_PAUSEABLE;
+       u32 full_xon_th = PFC_BRB_MAC_FULL_XON_THRESHOLD_PAUSEABLE;
+
+       if (set_pfc && pfc_params)
+               /* First COS */
+               if (!pfc_params->cos0_pauseable) {
+                       pause_xoff_th =
+                         PFC_BRB_MAC_PAUSE_XOFF_THRESHOLD_NON_PAUSEABLE;
+                       pause_xon_th =
+                         PFC_BRB_MAC_PAUSE_XON_THRESHOLD_NON_PAUSEABLE;
+                       full_xoff_th =
+                         PFC_BRB_MAC_FULL_XOFF_THRESHOLD_NON_PAUSEABLE;
+                       full_xon_th =
+                         PFC_BRB_MAC_FULL_XON_THRESHOLD_NON_PAUSEABLE;
+               }
+       /* The number of free blocks below which the pause signal to class 0
+          of MAC #n is asserted. n=0,1 */
+       REG_WR(bp, BRB1_REG_PAUSE_0_XOFF_THRESHOLD_0 , pause_xoff_th);
+       /* The number of free blocks above which the pause signal to class 0
+          of MAC #n is de-asserted. n=0,1 */
+       REG_WR(bp, BRB1_REG_PAUSE_0_XON_THRESHOLD_0 , pause_xon_th);
+       /* The number of free blocks below which the full signal to class 0
+          of MAC #n is asserted. n=0,1 */
+       REG_WR(bp, BRB1_REG_FULL_0_XOFF_THRESHOLD_0 , full_xoff_th);
+       /* The number of free blocks above which the full signal to class 0
+          of MAC #n is de-asserted. n=0,1 */
+       REG_WR(bp, BRB1_REG_FULL_0_XON_THRESHOLD_0 , full_xon_th);
+
+       if (set_pfc && pfc_params) {
+               /* Second COS */
+               if (pfc_params->cos1_pauseable) {
+                       pause_xoff_th =
+                         PFC_BRB_MAC_PAUSE_XOFF_THRESHOLD_PAUSEABLE;
+                       pause_xon_th =
+                         PFC_BRB_MAC_PAUSE_XON_THRESHOLD_PAUSEABLE;
+                       full_xoff_th =
+                         PFC_BRB_MAC_FULL_XOFF_THRESHOLD_PAUSEABLE;
+                       full_xon_th =
+                         PFC_BRB_MAC_FULL_XON_THRESHOLD_PAUSEABLE;
+               } else {
+                       pause_xoff_th =
+                         PFC_BRB_MAC_PAUSE_XOFF_THRESHOLD_NON_PAUSEABLE;
+                       pause_xon_th =
+                         PFC_BRB_MAC_PAUSE_XON_THRESHOLD_NON_PAUSEABLE;
+                       full_xoff_th =
+                         PFC_BRB_MAC_FULL_XOFF_THRESHOLD_NON_PAUSEABLE;
+                       full_xon_th =
+                         PFC_BRB_MAC_FULL_XON_THRESHOLD_NON_PAUSEABLE;
+               }
+               /**
+                * The number of free blocks below which the pause signal to
+                * class 1 of MAC #n is asserted. n=0,1
+                **/
+               REG_WR(bp, BRB1_REG_PAUSE_1_XOFF_THRESHOLD_0, pause_xoff_th);
+               /**
+                * The number of free blocks above which the pause signal to
+                * class 1 of MAC #n is de-asserted. n=0,1
+                **/
+               REG_WR(bp, BRB1_REG_PAUSE_1_XON_THRESHOLD_0, pause_xon_th);
+               /**
+                * The number of free blocks below which the full signal to
+                * class 1 of MAC #n is asserted. n=0,1
+                **/
+               REG_WR(bp, BRB1_REG_FULL_1_XOFF_THRESHOLD_0, full_xoff_th);
+               /**
+                * The number of free blocks above which the full signal to
+                * class 1 of MAC #n is de-asserted. n=0,1
+                **/
+               REG_WR(bp, BRB1_REG_FULL_1_XON_THRESHOLD_0, full_xon_th);
+       }
+}
+
+static void bnx2x_update_pfc_nig(struct link_params *params,
+               struct link_vars *vars,
+               struct bnx2x_nig_brb_pfc_port_params *nig_params)
+{
+       u32 xcm_mask = 0, ppp_enable = 0, pause_enable = 0, llfc_out_en = 0;
+       u32 llfc_enable = 0, xcm0_out_en = 0, p0_hwpfc_enable = 0;
+       u32 pkt_priority_to_cos = 0;
+       u32 val;
+       struct bnx2x *bp = params->bp;
+       int port = params->port;
+       int set_pfc = params->feature_config_flags &
+               FEATURE_CONFIG_PFC_ENABLED;
+       DP(NETIF_MSG_LINK, "updating pfc nig parameters\n");
+
+       /**
+        * When NIG_LLH0_XCM_MASK_REG_LLHX_XCM_MASK_BCN bit is set
+        * MAC control frames (that are not pause packets)
+        * will be forwarded to the XCM.
+        */
+       xcm_mask = REG_RD(bp,
+                               port ? NIG_REG_LLH1_XCM_MASK :
+                               NIG_REG_LLH0_XCM_MASK);
+       /**
+        * nig params will override non PFC params, since it's possible to
+        * do transition from PFC to SAFC
+        */
+       if (set_pfc) {
+               pause_enable = 0;
+               llfc_out_en = 0;
+               llfc_enable = 0;
+               ppp_enable = 1;
+               xcm_mask &= ~(port ? NIG_LLH1_XCM_MASK_REG_LLH1_XCM_MASK_BCN :
+                                    NIG_LLH0_XCM_MASK_REG_LLH0_XCM_MASK_BCN);
+               xcm0_out_en = 0;
+               p0_hwpfc_enable = 1;
+       } else  {
+               if (nig_params) {
+                       llfc_out_en = nig_params->llfc_out_en;
+                       llfc_enable = nig_params->llfc_enable;
+                       pause_enable = nig_params->pause_enable;
+               } else  /*defaul non PFC mode - PAUSE */
+                       pause_enable = 1;
+
+               xcm_mask |= (port ? NIG_LLH1_XCM_MASK_REG_LLH1_XCM_MASK_BCN :
+                       NIG_LLH0_XCM_MASK_REG_LLH0_XCM_MASK_BCN);
+               xcm0_out_en = 1;
+       }
+
+       REG_WR(bp, port ? NIG_REG_LLFC_OUT_EN_1 :
+              NIG_REG_LLFC_OUT_EN_0, llfc_out_en);
+       REG_WR(bp, port ? NIG_REG_LLFC_ENABLE_1 :
+              NIG_REG_LLFC_ENABLE_0, llfc_enable);
+       REG_WR(bp, port ? NIG_REG_PAUSE_ENABLE_1 :
+              NIG_REG_PAUSE_ENABLE_0, pause_enable);
+
+       REG_WR(bp, port ? NIG_REG_PPP_ENABLE_1 :
+              NIG_REG_PPP_ENABLE_0, ppp_enable);
+
+       REG_WR(bp, port ? NIG_REG_LLH1_XCM_MASK :
+              NIG_REG_LLH0_XCM_MASK, xcm_mask);
+
+       REG_WR(bp,  NIG_REG_LLFC_EGRESS_SRC_ENABLE_0, 0x7);
+
+       /* output enable for RX_XCM # IF */
+       REG_WR(bp, NIG_REG_XCM0_OUT_EN, xcm0_out_en);
+
+       /* HW PFC TX enable */
+       REG_WR(bp, NIG_REG_P0_HWPFC_ENABLE, p0_hwpfc_enable);
+
+       /* 0x2 = BMAC, 0x1= EMAC */
+       switch (vars->mac_type) {
+       case MAC_TYPE_EMAC:
+               val = 1;
+               break;
+       case MAC_TYPE_BMAC:
+               val = 0;
+               break;
+       default:
+               val = 0;
+               break;
+       }
+       REG_WR(bp, NIG_REG_EGRESS_EMAC0_PORT, val);
+
+       if (nig_params) {
+               pkt_priority_to_cos = nig_params->pkt_priority_to_cos;
+
+               REG_WR(bp, port ? NIG_REG_P1_RX_COS0_PRIORITY_MASK :
+                      NIG_REG_P0_RX_COS0_PRIORITY_MASK,
+                      nig_params->rx_cos0_priority_mask);
+
+               REG_WR(bp, port ? NIG_REG_P1_RX_COS1_PRIORITY_MASK :
+                      NIG_REG_P0_RX_COS1_PRIORITY_MASK,
+                      nig_params->rx_cos1_priority_mask);
+
+               REG_WR(bp, port ? NIG_REG_LLFC_HIGH_PRIORITY_CLASSES_1 :
+                      NIG_REG_LLFC_HIGH_PRIORITY_CLASSES_0,
+                      nig_params->llfc_high_priority_classes);
+
+               REG_WR(bp, port ? NIG_REG_LLFC_LOW_PRIORITY_CLASSES_1 :
+                      NIG_REG_LLFC_LOW_PRIORITY_CLASSES_0,
+                      nig_params->llfc_low_priority_classes);
+       }
+       REG_WR(bp, port ? NIG_REG_P1_PKT_PRIORITY_TO_COS :
+              NIG_REG_P0_PKT_PRIORITY_TO_COS,
+              pkt_priority_to_cos);
+}
+
+
+void bnx2x_update_pfc(struct link_params *params,
+                     struct link_vars *vars,
+                     struct bnx2x_nig_brb_pfc_port_params *pfc_params)
+{
+       /**
+        * The PFC and pause are orthogonal to one another, meaning when
+        * PFC is enabled, the pause are disabled, and when PFC is
+        * disabled, pause are set according to the pause result.
+        */
+       u32 val;
+       struct bnx2x *bp = params->bp;
+
+       /* update NIG params */
+       bnx2x_update_pfc_nig(params, vars, pfc_params);
+
+       /* update BRB params */
+       bnx2x_update_pfc_brb(params, vars, pfc_params);
+
+       if (!vars->link_up)
+               return;
+
+       val = REG_RD(bp, MISC_REG_RESET_REG_2);
+       if ((val & (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << params->port))
+           == 0) {
+               DP(NETIF_MSG_LINK, "About to update PFC in EMAC\n");
+               bnx2x_emac_enable(params, vars, 0);
+               return;
+       }
+
+       DP(NETIF_MSG_LINK, "About to update PFC in BMAC\n");
+       if (CHIP_IS_E2(bp))
+               bnx2x_update_pfc_bmac2(params, vars, 0);
+       else
+               bnx2x_update_pfc_bmac1(params, vars);
+
+       val = 0;
+       if ((params->feature_config_flags &
+             FEATURE_CONFIG_PFC_ENABLED) ||
+           (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX))
+               val = 1;
+       REG_WR(bp, NIG_REG_BMAC0_PAUSE_OUT_EN + params->port*4, val);
+}
 
 static u8 bnx2x_bmac1_enable(struct link_params *params,
                             struct link_vars *vars,
@@ -465,15 +1063,6 @@ static u8 bnx2x_bmac1_enable(struct link_params *params,
        REG_WR_DMAE(bp, bmac_addr + BIGMAC_REGISTER_TX_SOURCE_ADDR,
                    wb_data, 2);
 
-       /* tx control */
-       val = 0xc0;
-       if (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX)
-               val |= 0x800000;
-       wb_data[0] = val;
-       wb_data[1] = 0;
-       REG_WR_DMAE(bp, bmac_addr + BIGMAC_REGISTER_TX_CONTROL,
-                       wb_data, 2);
-
        /* mac control */
        val = 0x3;
        if (is_lb) {
@@ -491,14 +1080,7 @@ static u8 bnx2x_bmac1_enable(struct link_params *params,
        REG_WR_DMAE(bp, bmac_addr + BIGMAC_REGISTER_RX_MAX_SIZE,
                        wb_data, 2);
 
-       /* rx control set to don't strip crc */
-       val = 0x14;
-       if (vars->flow_ctrl & BNX2X_FLOW_CTRL_RX)
-               val |= 0x20;
-       wb_data[0] = val;
-       wb_data[1] = 0;
-       REG_WR_DMAE(bp, bmac_addr + BIGMAC_REGISTER_RX_CONTROL,
-                       wb_data, 2);
+       bnx2x_update_pfc_bmac1(params, vars);
 
        /* set tx mtu */
        wb_data[0] = ETH_MAX_JUMBO_PACKET_SIZE + ETH_OVREHEAD;
@@ -595,7 +1177,7 @@ static u8 bnx2x_bmac2_enable(struct link_params *params,
        REG_WR_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_CNT_MAX_SIZE,
                        wb_data, 2);
        udelay(30);
-       bnx2x_update_bmac2(params, vars, is_lb);
+       bnx2x_update_pfc_bmac2(params, vars, is_lb);
 
        return 0;
 }
@@ -627,7 +1209,9 @@ static u8 bnx2x_bmac_enable(struct link_params *params,
        REG_WR(bp, NIG_REG_XGXS_LANE_SEL_P0 + port*4, 0x0);
        REG_WR(bp, NIG_REG_EGRESS_EMAC0_PORT + port*4, 0x0);
        val = 0;
-       if (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX)
+       if ((params->feature_config_flags &
+             FEATURE_CONFIG_PFC_ENABLED) ||
+           (vars->flow_ctrl & BNX2X_FLOW_CTRL_TX))
                val = 1;
        REG_WR(bp, NIG_REG_BMAC0_PAUSE_OUT_EN + port*4, val);
        REG_WR(bp, NIG_REG_EGRESS_EMAC0_OUT_EN + port*4, 0x0);
@@ -989,7 +1573,7 @@ static void bnx2x_set_aer_mmd_xgxs(struct link_params *params,
 
        offset = phy->addr + ser_lane;
        if (CHIP_IS_E2(bp))
-               aer_val = 0x2800 + offset - 1;
+               aer_val = 0x3800 + offset - 1;
        else
                aer_val = 0x3800 + offset;
        CL45_WR_OVER_CL22(bp, phy,
@@ -2582,7 +3166,23 @@ u8 bnx2x_set_led(struct link_params *params,
                if (!vars->link_up)
                        break;
        case LED_MODE_ON:
-               if (SINGLE_MEDIA_DIRECT(params)) {
+               if (params->phy[EXT_PHY1].type ==
+                   PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727 &&
+                   CHIP_IS_E2(bp) && params->num_phys == 2) {
+                       /**
+                       * This is a work-around for E2+8727 Configurations
+                       */
+                       if (mode == LED_MODE_ON ||
+                               speed == SPEED_10000){
+                               REG_WR(bp, NIG_REG_LED_MODE_P0 + port*4, 0);
+                               REG_WR(bp, NIG_REG_LED_10G_P0 + port*4, 1);
+
+                               tmp = EMAC_RD(bp, EMAC_REG_EMAC_LED);
+                               EMAC_WR(bp, EMAC_REG_EMAC_LED,
+                                       (tmp | EMAC_LED_OVERRIDE));
+                               return rc;
+                       }
+               } else if (SINGLE_MEDIA_DIRECT(params)) {
                        /**
                        * This is a work-around for HW issue found when link
                        * is up in CL73
@@ -3270,11 +3870,14 @@ static void bnx2x_8073_resolve_fc(struct bnx2x_phy *phy,
                           pause_result);
        }
 }
-
-static void bnx2x_8073_8727_external_rom_boot(struct bnx2x *bp,
+static u8 bnx2x_8073_8727_external_rom_boot(struct bnx2x *bp,
                                              struct bnx2x_phy *phy,
                                              u8 port)
 {
+       u32 count = 0;
+       u16 fw_ver1, fw_msgout;
+       u8 rc = 0;
+
        /* Boot port from external ROM  */
        /* EDC grst */
        bnx2x_cl45_write(bp, phy,
@@ -3304,56 +3907,45 @@ static void bnx2x_8073_8727_external_rom_boot(struct bnx2x *bp,
                       MDIO_PMA_REG_GEN_CTRL,
                       MDIO_PMA_REG_GEN_CTRL_ROM_RESET_INTERNAL_MP);
 
-       /* wait for 120ms for code download via SPI port */
-       msleep(120);
+       /* Delay 100ms per the PHY specifications */
+       msleep(100);
+
+       /* 8073 sometimes taking longer to download */
+       do {
+               count++;
+               if (count > 300) {
+                       DP(NETIF_MSG_LINK,
+                                "bnx2x_8073_8727_external_rom_boot port %x:"
+                                "Download failed. fw version = 0x%x\n",
+                                port, fw_ver1);
+                       rc = -EINVAL;
+                       break;
+               }
+
+               bnx2x_cl45_read(bp, phy,
+                               MDIO_PMA_DEVAD,
+                               MDIO_PMA_REG_ROM_VER1, &fw_ver1);
+               bnx2x_cl45_read(bp, phy,
+                               MDIO_PMA_DEVAD,
+                               MDIO_PMA_REG_M8051_MSGOUT_REG, &fw_msgout);
+
+               msleep(1);
+       } while (fw_ver1 == 0 || fw_ver1 == 0x4321 ||
+                       ((fw_msgout & 0xff) != 0x03 && (phy->type ==
+                       PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073)));
 
        /* Clear ser_boot_ctl bit */
        bnx2x_cl45_write(bp, phy,
                       MDIO_PMA_DEVAD,
                       MDIO_PMA_REG_MISC_CTRL1, 0x0000);
        bnx2x_save_bcm_spirom_ver(bp, phy, port);
-}
 
-static void bnx2x_8073_set_xaui_low_power_mode(struct bnx2x *bp,
-                                              struct bnx2x_phy *phy)
-{
-       u16 val;
-       bnx2x_cl45_read(bp, phy,
-                       MDIO_PMA_DEVAD, MDIO_PMA_REG_8073_CHIP_REV, &val);
-
-       if (val == 0) {
-               /* Mustn't set low power mode in 8073 A0 */
-               return;
-       }
-
-       /* Disable PLL sequencer (use read-modify-write to clear bit 13) */
-       bnx2x_cl45_read(bp, phy,
-                       MDIO_XS_DEVAD, MDIO_XS_PLL_SEQUENCER, &val);
-       val &= ~(1<<13);
-       bnx2x_cl45_write(bp, phy,
-                      MDIO_XS_DEVAD, MDIO_XS_PLL_SEQUENCER, val);
-
-       /* PLL controls */
-       bnx2x_cl45_write(bp, phy, MDIO_XS_DEVAD, 0x805E, 0x1077);
-       bnx2x_cl45_write(bp, phy, MDIO_XS_DEVAD, 0x805D, 0x0000);
-       bnx2x_cl45_write(bp, phy, MDIO_XS_DEVAD, 0x805C, 0x030B);
-       bnx2x_cl45_write(bp, phy, MDIO_XS_DEVAD, 0x805B, 0x1240);
-       bnx2x_cl45_write(bp, phy, MDIO_XS_DEVAD, 0x805A, 0x2490);
-
-       /* Tx Controls */
-       bnx2x_cl45_write(bp, phy, MDIO_XS_DEVAD, 0x80A7, 0x0C74);
-       bnx2x_cl45_write(bp, phy, MDIO_XS_DEVAD, 0x80A6, 0x9041);
-       bnx2x_cl45_write(bp, phy, MDIO_XS_DEVAD, 0x80A5, 0x4640);
-
-       /* Rx Controls */
-       bnx2x_cl45_write(bp, phy, MDIO_XS_DEVAD, 0x80FE, 0x01C4);
-       bnx2x_cl45_write(bp, phy, MDIO_XS_DEVAD, 0x80FD, 0x9249);
-       bnx2x_cl45_write(bp, phy, MDIO_XS_DEVAD, 0x80FC, 0x2015);
+       DP(NETIF_MSG_LINK,
+                "bnx2x_8073_8727_external_rom_boot port %x:"
+                "Download complete. fw version = 0x%x\n",
+                port, fw_ver1);
 
-       /* Enable PLL sequencer  (use read-modify-write to set bit 13) */
-       bnx2x_cl45_read(bp, phy, MDIO_XS_DEVAD, MDIO_XS_PLL_SEQUENCER, &val);
-       val |= (1<<13);
-       bnx2x_cl45_write(bp, phy, MDIO_XS_DEVAD, MDIO_XS_PLL_SEQUENCER, val);
+       return rc;
 }
 
 /******************************************************************/
@@ -3514,8 +4106,6 @@ static u8 bnx2x_8073_config_init(struct bnx2x_phy *phy,
 
        bnx2x_8073_set_pause_cl37(params, phy, vars);
 
-       bnx2x_8073_set_xaui_low_power_mode(bp, phy);
-
        bnx2x_cl45_read(bp, phy,
                        MDIO_PMA_DEVAD, MDIO_PMA_REG_M8051_MSGOUT_REG, &tmp1);
 
@@ -3524,6 +4114,25 @@ static u8 bnx2x_8073_config_init(struct bnx2x_phy *phy,
 
        DP(NETIF_MSG_LINK, "Before rom RX_ALARM(port1): 0x%x\n", tmp1);
 
+       /**
+        * If this is forced speed, set to KR or KX (all other are not
+        * supported)
+        */
+       /* Swap polarity if required - Must be done only in non-1G mode */
+       if (params->lane_config & PORT_HW_CFG_SWAP_PHY_POLARITY_ENABLED) {
+               /* Configure the 8073 to swap _P and _N of the KR lines */
+               DP(NETIF_MSG_LINK, "Swapping polarity for the 8073\n");
+               /* 10G Rx/Tx and 1G Tx signal polarity swap */
+               bnx2x_cl45_read(bp, phy,
+                               MDIO_PMA_DEVAD,
+                               MDIO_PMA_REG_8073_OPT_DIGITAL_CTRL, &val);
+               bnx2x_cl45_write(bp, phy,
+                                MDIO_PMA_DEVAD,
+                                MDIO_PMA_REG_8073_OPT_DIGITAL_CTRL,
+                                (val | (3<<9)));
+       }
+
+
        /* Enable CL37 BAM */
        if (REG_RD(bp, params->shmem_base +
                         offsetof(struct shmem_region, dev_info.
@@ -3730,8 +4339,32 @@ static u8 bnx2x_8073_read_status(struct bnx2x_phy *phy,
        }
 
        if (link_up) {
+               /* Swap polarity if required */
+               if (params->lane_config &
+                   PORT_HW_CFG_SWAP_PHY_POLARITY_ENABLED) {
+                       /* Configure the 8073 to swap P and N of the KR lines */
+                       bnx2x_cl45_read(bp, phy,
+                                       MDIO_XS_DEVAD,
+                                       MDIO_XS_REG_8073_RX_CTRL_PCIE, &val1);
+                       /**
+                       * Set bit 3 to invert Rx in 1G mode and clear this bit
+                       * when it`s in 10G mode.
+                       */
+                       if (vars->line_speed == SPEED_1000) {
+                               DP(NETIF_MSG_LINK, "Swapping 1G polarity for"
+                                             "the 8073\n");
+                               val1 |= (1<<3);
+                       } else
+                               val1 &= ~(1<<3);
+
+                       bnx2x_cl45_write(bp, phy,
+                                        MDIO_XS_DEVAD,
+                                        MDIO_XS_REG_8073_RX_CTRL_PCIE,
+                                        val1);
+               }
                bnx2x_ext_phy_10G_an_resolve(bp, phy, vars);
                bnx2x_8073_resolve_fc(phy, params, vars);
+               vars->duplex = DUPLEX_FULL;
        }
        return link_up;
 }
@@ -3904,7 +4537,7 @@ static u8 bnx2x_8726_read_sfp_module_eeprom(struct bnx2x_phy *phy,
                              MDIO_PMA_REG_SFP_TWO_WIRE_CTRL, &val);
                if ((val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK) ==
                    MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_IDLE)
-                       return 0;;
+                       return 0;
                msleep(1);
        }
        return -EINVAL;
@@ -3988,7 +4621,7 @@ static u8 bnx2x_8727_read_sfp_module_eeprom(struct bnx2x_phy *phy,
                              MDIO_PMA_REG_SFP_TWO_WIRE_CTRL, &val);
                if ((val & MDIO_PMA_REG_SFP_TWO_WIRE_CTRL_STATUS_MASK) ==
                    MDIO_PMA_REG_SFP_TWO_WIRE_STATUS_IDLE)
-                       return 0;;
+                       return 0;
                msleep(1);
        }
 
@@ -4478,6 +5111,7 @@ static u8 bnx2x_8706_8726_read_status(struct bnx2x_phy *phy,
                else
                        vars->line_speed = SPEED_10000;
                bnx2x_ext_phy_resolve_fc(phy, params, vars);
+               vars->duplex = DUPLEX_FULL;
        }
        return link_up;
 }
@@ -5174,8 +5808,11 @@ static u8 bnx2x_8727_read_status(struct bnx2x_phy *phy,
                DP(NETIF_MSG_LINK, "port %x: External link is down\n",
                           params->port);
        }
-       if (link_up)
+       if (link_up) {
                bnx2x_ext_phy_resolve_fc(phy, params, vars);
+               vars->duplex = DUPLEX_FULL;
+               DP(NETIF_MSG_LINK, "duplex = 0x%x\n", vars->duplex);
+       }
 
        if ((DUAL_MEDIA(params)) &&
            (phy->req_line_speed == SPEED_1000)) {
@@ -5291,10 +5928,26 @@ static void bnx2x_848xx_set_led(struct bnx2x *bp,
                         MDIO_PMA_REG_8481_LED2_MASK,
                         0x18);
 
+       /* Select activity source by Tx and Rx, as suggested by PHY AE */
        bnx2x_cl45_write(bp, phy,
                         MDIO_PMA_DEVAD,
                         MDIO_PMA_REG_8481_LED3_MASK,
-                        0x0040);
+                        0x0006);
+
+       /* Select the closest activity blink rate to that in 10/100/1000 */
+       bnx2x_cl45_write(bp, phy,
+                       MDIO_PMA_DEVAD,
+                       MDIO_PMA_REG_8481_LED3_BLINK,
+                       0);
+
+       bnx2x_cl45_read(bp, phy,
+                       MDIO_PMA_DEVAD,
+                       MDIO_PMA_REG_84823_CTL_LED_CTL_1, &val);
+       val |= MDIO_PMA_REG_84823_LED3_STRETCH_EN; /* stretch_en for LED3*/
+
+       bnx2x_cl45_write(bp, phy,
+                        MDIO_PMA_DEVAD,
+                        MDIO_PMA_REG_84823_CTL_LED_CTL_1, val);
 
        /* 'Interrupt Mask' */
        bnx2x_cl45_write(bp, phy,
@@ -5542,6 +6195,7 @@ static u8 bnx2x_848xx_read_status(struct bnx2x_phy *phy,
        /* Check link 10G */
        if (val2 & (1<<11)) {
                vars->line_speed = SPEED_10000;
+               vars->duplex = DUPLEX_FULL;
                link_up = 1;
                bnx2x_ext_phy_10G_an_resolve(bp, phy, vars);
        } else { /* Check Legacy speed link */
@@ -5821,6 +6475,18 @@ static void bnx2x_848xx_set_link_led(struct bnx2x_phy *phy,
                                         MDIO_PMA_DEVAD,
                                         MDIO_PMA_REG_8481_LED1_MASK,
                                         0x80);
+
+                       /* Tell LED3 to blink on source */
+                       bnx2x_cl45_read(bp, phy,
+                                       MDIO_PMA_DEVAD,
+                                       MDIO_PMA_REG_8481_LINK_SIGNAL,
+                                       &val);
+                       val &= ~(7<<6);
+                       val |= (1<<6); /* A83B[8:6]= 1 */
+                       bnx2x_cl45_write(bp, phy,
+                                        MDIO_PMA_DEVAD,
+                                        MDIO_PMA_REG_8481_LINK_SIGNAL,
+                                        val);
                }
                break;
        }
@@ -5905,6 +6571,7 @@ static u8 bnx2x_7101_read_status(struct bnx2x_phy *phy,
                                MDIO_AN_DEVAD, MDIO_AN_REG_MASTER_STATUS,
                                &val2);
                vars->line_speed = SPEED_10000;
+               vars->duplex = DUPLEX_FULL;
                DP(NETIF_MSG_LINK, "SFX7101 AN status 0x%x->Master=%x\n",
                           val2, (val2 & (1<<14)));
                bnx2x_ext_phy_10G_an_resolve(bp, phy, vars);
@@ -7021,10 +7688,13 @@ static u8 bnx2x_8073_common_init_phy(struct bnx2x *bp,
        struct bnx2x_phy phy[PORT_MAX];
        struct bnx2x_phy *phy_blk[PORT_MAX];
        u16 val;
-       s8 port;
+       s8 port = 0;
        s8 port_of_path = 0;
-
-       bnx2x_ext_phy_hw_reset(bp, 0);
+       u32 swap_val, swap_override;
+       swap_val = REG_RD(bp,  NIG_REG_PORT_SWAP);
+       swap_override = REG_RD(bp,  NIG_REG_STRAP_OVERRIDE);
+       port ^= (swap_val && swap_override);
+       bnx2x_ext_phy_hw_reset(bp, port);
        /* PART1 - Reset both phys */
        for (port = PORT_MAX - 1; port >= PORT_0; port--) {
                u32 shmem_base, shmem2_base;
@@ -7079,7 +7749,6 @@ static u8 bnx2x_8073_common_init_phy(struct bnx2x *bp,
 
        /* PART2 - Download firmware to both phys */
        for (port = PORT_MAX - 1; port >= PORT_0; port--) {
-               u16 fw_ver1;
                if (CHIP_IS_E2(bp))
                        port_of_path = 0;
                else
@@ -7087,19 +7756,9 @@ static u8 bnx2x_8073_common_init_phy(struct bnx2x *bp,
 
                DP(NETIF_MSG_LINK, "Loading spirom for phy address 0x%x\n",
                           phy_blk[port]->addr);
-               bnx2x_8073_8727_external_rom_boot(bp, phy_blk[port],
-                                                 port_of_path);
-
-               bnx2x_cl45_read(bp, phy_blk[port],
-                             MDIO_PMA_DEVAD,
-                             MDIO_PMA_REG_ROM_VER1, &fw_ver1);
-               if (fw_ver1 == 0 || fw_ver1 == 0x4321) {
-                       DP(NETIF_MSG_LINK,
-                                "bnx2x_8073_common_init_phy port %x:"
-                                "Download failed. fw version = 0x%x\n",
-                                port, fw_ver1);
+               if (bnx2x_8073_8727_external_rom_boot(bp, phy_blk[port],
+                                                     port_of_path))
                        return -EINVAL;
-               }
 
                /* Only set bit 10 = 1 (Tx power down) */
                bnx2x_cl45_read(bp, phy_blk[port],
@@ -7264,27 +7923,17 @@ static u8 bnx2x_8727_common_init_phy(struct bnx2x *bp,
        }
        /* PART2 - Download firmware to both phys */
        for (port = PORT_MAX - 1; port >= PORT_0; port--) {
-               u16 fw_ver1;
                 if (CHIP_IS_E2(bp))
                        port_of_path = 0;
                else
                        port_of_path = port;
                DP(NETIF_MSG_LINK, "Loading spirom for phy address 0x%x\n",
                           phy_blk[port]->addr);
-               bnx2x_8073_8727_external_rom_boot(bp, phy_blk[port],
-                                                 port_of_path);
-               bnx2x_cl45_read(bp, phy_blk[port],
-                             MDIO_PMA_DEVAD,
-                             MDIO_PMA_REG_ROM_VER1, &fw_ver1);
-               if (fw_ver1 == 0 || fw_ver1 == 0x4321) {
-                       DP(NETIF_MSG_LINK,
-                                "bnx2x_8727_common_init_phy port %x:"
-                                "Download failed. fw version = 0x%x\n",
-                                port, fw_ver1);
+               if (bnx2x_8073_8727_external_rom_boot(bp, phy_blk[port],
+                                                     port_of_path))
                        return -EINVAL;
-               }
-       }
 
+       }
        return 0;
 }
 
@@ -7332,6 +7981,7 @@ u8 bnx2x_common_init_phy(struct bnx2x *bp, u32 shmem_base_path[],
                         u32 shmem2_base_path[], u32 chip_id)
 {
        u8 rc = 0;
+       u32 phy_ver;
        u8 phy_index;
        u32 ext_phy_type, ext_phy_config;
        DP(NETIF_MSG_LINK, "Begin common phy init\n");
@@ -7339,6 +7989,16 @@ u8 bnx2x_common_init_phy(struct bnx2x *bp, u32 shmem_base_path[],
        if (CHIP_REV_IS_EMUL(bp))
                return 0;
 
+       /* Check if common init was already done */
+       phy_ver = REG_RD(bp, shmem_base_path[0] +
+                        offsetof(struct shmem_region,
+                                 port_mb[PORT_0].ext_phy_fw_version));
+       if (phy_ver) {
+               DP(NETIF_MSG_LINK, "Not doing common init; phy ver is 0x%x\n",
+                              phy_ver);
+               return 0;
+       }
+
        /* Read the ext_phy_type for arbitrary port(0) */
        for (phy_index = EXT_PHY1; phy_index < MAX_PHYS;
              phy_index++) {