Author: arybchik
Date: Fri Feb 20 07:57:59 2015
New Revision: 279048
URL: https://svnweb.freebsd.org/changeset/base/279048

Log:
  sfxge: add Florence R7 turbo mode support to common code
  
  Submitted by:   Andrew Lee <alee at solarflare.com>
  Sponsored by:   Solarflare Communications, Inc.
  Approved by:    gnn (mentor)

Modified:
  head/sys/dev/sfxge/common/efx.h
  head/sys/dev/sfxge/common/efx_ev.c
  head/sys/dev/sfxge/common/efx_mcdi.h
  head/sys/dev/sfxge/common/siena_nic.c

Modified: head/sys/dev/sfxge/common/efx.h
==============================================================================
--- head/sys/dev/sfxge/common/efx.h     Fri Feb 20 07:54:35 2015        
(r279047)
+++ head/sys/dev/sfxge/common/efx.h     Fri Feb 20 07:57:59 2015        
(r279048)
@@ -861,6 +861,7 @@ efx_phy_bist_stop(
 #define        EFX_FEATURE_MCDI                0x00000020
 #define        EFX_FEATURE_LOOKAHEAD_SPLIT     0x00000040
 #define        EFX_FEATURE_MAC_HEADER_FILTERS  0x00000080
+#define        EFX_FEATURE_TURBO               0x00000100
 
 typedef struct efx_nic_cfg_s {
        uint32_t                enc_board_type;
@@ -881,6 +882,7 @@ typedef struct efx_nic_cfg_s {
        uint32_t                enc_rxq_limit;
        uint32_t                enc_buftbl_limit;
        uint32_t                enc_evq_moderation_max;
+       uint32_t                enc_clk_mult;
 #if EFSYS_OPT_LOOPBACK
        uint32_t                enc_loopback_types[EFX_LINK_NMODES];
 #endif /* EFSYS_OPT_LOOPBACK */

Modified: head/sys/dev/sfxge/common/efx_ev.c
==============================================================================
--- head/sys/dev/sfxge/common/efx_ev.c  Fri Feb 20 07:54:35 2015        
(r279047)
+++ head/sys/dev/sfxge/common/efx_ev.c  Fri Feb 20 07:57:59 2015        
(r279048)
@@ -844,13 +844,14 @@ efx_ev_qmoderate(
        __in            unsigned int us)
 {
        efx_nic_t *enp = eep->ee_enp;
+       efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
        unsigned int locked;
        efx_dword_t dword;
        int rc;
 
        EFSYS_ASSERT3U(eep->ee_magic, ==, EFX_EVQ_MAGIC);
 
-       if (us > enp->en_nic_cfg.enc_evq_moderation_max) {
+       if (us > encp->enc_evq_moderation_max) {
                rc = EINVAL;
                goto fail1;
        }
@@ -869,21 +870,20 @@ efx_ev_qmoderate(
                uint32_t timer_val;
 
                /* Calculate the timer value in quanta */
-               us -= (us % EFX_EV_TIMER_QUANTUM);
-               if (us < EFX_EV_TIMER_QUANTUM)
-                       us = EFX_EV_TIMER_QUANTUM;
-
-               timer_val = us / EFX_EV_TIMER_QUANTUM;
+               timer_val = us * encp->enc_clk_mult / EFX_EV_TIMER_QUANTUM;
 
                /* Moderation value is base 0 so we need to deduct 1 */
+               if (timer_val > 0)
+                       timer_val--;
+
                if (enp->en_family == EFX_FAMILY_FALCON)
                        EFX_POPULATE_DWORD_2(dword,
                            FRF_AB_TC_TIMER_MODE, FFE_AB_TIMER_MODE_INT_HLDOFF,
-                           FRF_AB_TIMER_VAL, timer_val - 1);
+                           FRF_AB_TIMER_VAL, timer_val);
                else
                        EFX_POPULATE_DWORD_2(dword,
                            FRF_CZ_TC_TIMER_MODE, FFE_CZ_TIMER_MODE_INT_HLDOFF,
-                           FRF_CZ_TC_TIMER_VAL, timer_val - 1);
+                           FRF_CZ_TC_TIMER_VAL, timer_val);
        }
 
        locked = (eep->ee_index == 0) ? 1 : 0;

Modified: head/sys/dev/sfxge/common/efx_mcdi.h
==============================================================================
--- head/sys/dev/sfxge/common/efx_mcdi.h        Fri Feb 20 07:54:35 2015        
(r279047)
+++ head/sys/dev/sfxge/common/efx_mcdi.h        Fri Feb 20 07:57:59 2015        
(r279048)
@@ -233,6 +233,9 @@ efx_mcdi_version(
 #define        MCDI_EV_FIELD(_eqp, _field)                                     
\
        EFX_QWORD_FIELD(*_eqp, MCDI_EVENT_ ## _field)
 
+#define MCDI_CMD_DWORD_FIELD(_edp, _field)                             \
+       EFX_DWORD_FIELD(*_edp, MC_CMD_ ## _field)
+
 #ifdef __cplusplus
 }
 #endif

Modified: head/sys/dev/sfxge/common/siena_nic.c
==============================================================================
--- head/sys/dev/sfxge/common/siena_nic.c       Fri Feb 20 07:54:35 2015        
(r279047)
+++ head/sys/dev/sfxge/common/siena_nic.c       Fri Feb 20 07:57:59 2015        
(r279048)
@@ -279,7 +279,8 @@ siena_board_cfg(
        uint8_t outbuf[MAX(MC_CMD_GET_BOARD_CFG_OUT_LENMIN,
                    MC_CMD_GET_RESOURCE_LIMITS_OUT_LEN)];
        efx_mcdi_req_t req;
-       uint8_t *src;
+       uint8_t *mac_addr;
+       efx_dword_t *capabilities;
        int rc;
 
        /* Board configuration */
@@ -302,17 +303,35 @@ siena_board_cfg(
                goto fail2;
        }
 
-       if (emip->emi_port == 1)
-               src = MCDI_OUT2(req, uint8_t,
+       if (emip->emi_port == 1) {
+               mac_addr = MCDI_OUT2(req, uint8_t,
                            GET_BOARD_CFG_OUT_MAC_ADDR_BASE_PORT0);
-       else
-               src = MCDI_OUT2(req, uint8_t,
+               capabilities = MCDI_OUT2(req, efx_dword_t,
+                           GET_BOARD_CFG_OUT_CAPABILITIES_PORT0);
+       } else {
+               mac_addr = MCDI_OUT2(req, uint8_t,
                            GET_BOARD_CFG_OUT_MAC_ADDR_BASE_PORT1);
-       EFX_MAC_ADDR_COPY(encp->enc_mac_addr, src);
+               capabilities = MCDI_OUT2(req, efx_dword_t,
+                           GET_BOARD_CFG_OUT_CAPABILITIES_PORT1);
+       }
+       EFX_MAC_ADDR_COPY(encp->enc_mac_addr, mac_addr);
 
        encp->enc_board_type = MCDI_OUT_DWORD(req,
                                    GET_BOARD_CFG_OUT_BOARD_TYPE);
 
+       /* Additional capabilities */
+       encp->enc_clk_mult = 1;
+       if (MCDI_CMD_DWORD_FIELD(capabilities, CAPABILITIES_TURBO)) {
+               enp->en_features |= EFX_FEATURE_TURBO;
+
+               if (MCDI_CMD_DWORD_FIELD(capabilities,
+                   CAPABILITIES_TURBO_ACTIVE))
+                       encp->enc_clk_mult = 2;
+       }
+
+       encp->enc_evq_moderation_max = EFX_EV_TIMER_QUANTUM <<
+               FRF_AB_TIMER_VAL_WIDTH / encp->enc_clk_mult;
+
        /* Resource limits */
        req.emr_cmd = MC_CMD_GET_RESOURCE_LIMITS;
        EFX_STATIC_ASSERT(MC_CMD_GET_RESOURCE_LIMITS_IN_LEN == 0);
@@ -608,9 +627,6 @@ siena_nic_probe(
        if ((rc = siena_board_cfg(enp)) != 0)
                goto fail4;
 
-       encp->enc_evq_moderation_max =
-               EFX_EV_TIMER_QUANTUM << FRF_CZ_TIMER_VAL_WIDTH;
-
        if ((rc = siena_phy_cfg(enp)) != 0)
                goto fail5;
 
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to