aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/sfc
diff options
context:
space:
mode:
authorBen Hutchings <bhutchings@solarflare.com>2009-10-23 04:30:06 -0400
committerDavid S. Miller <davem@davemloft.net>2009-10-24 07:26:56 -0400
commit56241ceb9e75fc1a5fb142a754096ad6c6ab19ee (patch)
tree8ae854f3176aff0b478cb56db611e68a3f901a1f /drivers/net/sfc
parent5087b54ddc4f3a1007c0984177934c016d884639 (diff)
sfc: Remove versioned bitfield macros
These macros are not extensible to more than two NIC types without repetition of register definitions, and they are only used to deal with a few fields in RX_CFG_REG and global events which moved between Falcon rev A1 and B0. Therefore: - Move RX_CFG_REG initialisation into its own function which tests the NIC revision just once - Explicitly test the NIC revision when checking the RX_RECOVERY flag in global events - Merge definitions of RX_XOFF_MAC_EN flag, which did not move - Remove the macro definitions Signed-off-by: Ben Hutchings <bhutchings@solarflare.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/sfc')
-rw-r--r--drivers/net/sfc/bitfield.h13
-rw-r--r--drivers/net/sfc/falcon.c67
-rw-r--r--drivers/net/sfc/falcon_hwdefs.h7
3 files changed, 47 insertions, 40 deletions
diff --git a/drivers/net/sfc/bitfield.h b/drivers/net/sfc/bitfield.h
index d54d84c267b9..6ad909bba957 100644
--- a/drivers/net/sfc/bitfield.h
+++ b/drivers/net/sfc/bitfield.h
@@ -520,19 +520,6 @@ typedef union efx_oword {
520#define EFX_SET_QWORD_FIELD EFX_SET_QWORD_FIELD32 520#define EFX_SET_QWORD_FIELD EFX_SET_QWORD_FIELD32
521#endif 521#endif
522 522
523#define EFX_SET_OWORD_FIELD_VER(efx, oword, field, value) do { \
524 if (falcon_rev(efx) >= FALCON_REV_B0) { \
525 EFX_SET_OWORD_FIELD((oword), field##_B0, (value)); \
526 } else { \
527 EFX_SET_OWORD_FIELD((oword), field##_A1, (value)); \
528 } \
529} while (0)
530
531#define EFX_QWORD_FIELD_VER(efx, qword, field) \
532 (falcon_rev(efx) >= FALCON_REV_B0 ? \
533 EFX_QWORD_FIELD((qword), field##_B0) : \
534 EFX_QWORD_FIELD((qword), field##_A1))
535
536/* Used to avoid compiler warnings about shift range exceeding width 523/* Used to avoid compiler warnings about shift range exceeding width
537 * of the data types when dma_addr_t is only 32 bits wide. 524 * of the data types when dma_addr_t is only 32 bits wide.
538 */ 525 */
diff --git a/drivers/net/sfc/falcon.c b/drivers/net/sfc/falcon.c
index eed8d1f98dd0..4cb98d473c4d 100644
--- a/drivers/net/sfc/falcon.c
+++ b/drivers/net/sfc/falcon.c
@@ -929,7 +929,9 @@ static void falcon_handle_global_event(struct efx_channel *channel,
929 handled = true; 929 handled = true;
930 } 930 }
931 931
932 if (EFX_QWORD_FIELD_VER(efx, *event, RX_RECOVERY)) { 932 if (falcon_rev(efx) <= FALCON_REV_A1 ?
933 EFX_QWORD_FIELD(*event, RX_RECOVERY_A1) :
934 EFX_QWORD_FIELD(*event, RX_RECOVERY_B0)) {
933 EFX_ERR(efx, "channel %d seen global RX_RESET " 935 EFX_ERR(efx, "channel %d seen global RX_RESET "
934 "event. Resetting.\n", channel->channel); 936 "event. Resetting.\n", channel->channel);
935 937
@@ -2006,7 +2008,7 @@ void falcon_reconfigure_mac_wrapper(struct efx_nic *efx)
2006 * Action on receipt of pause frames is controller by XM_DIS_FCNTL */ 2008 * Action on receipt of pause frames is controller by XM_DIS_FCNTL */
2007 tx_fc = !!(efx->link_fc & EFX_FC_TX); 2009 tx_fc = !!(efx->link_fc & EFX_FC_TX);
2008 falcon_read(efx, &reg, RX_CFG_REG_KER); 2010 falcon_read(efx, &reg, RX_CFG_REG_KER);
2009 EFX_SET_OWORD_FIELD_VER(efx, reg, RX_XOFF_MAC_EN, tx_fc); 2011 EFX_SET_OWORD_FIELD(reg, RX_XOFF_MAC_EN, tx_fc);
2010 2012
2011 /* Unisolate the MAC -> RX */ 2013 /* Unisolate the MAC -> RX */
2012 if (falcon_rev(efx) >= FALCON_REV_B0) 2014 if (falcon_rev(efx) >= FALCON_REV_B0)
@@ -2910,6 +2912,45 @@ int falcon_probe_nic(struct efx_nic *efx)
2910 return rc; 2912 return rc;
2911} 2913}
2912 2914
2915static void falcon_init_rx_cfg(struct efx_nic *efx)
2916{
2917 /* Prior to Siena the RX DMA engine will split each frame at
2918 * intervals of RX_USR_BUF_SIZE (32-byte units). We set it to
2919 * be so large that that never happens. */
2920 const unsigned huge_buf_size = (3 * 4096) >> 5;
2921 /* RX control FIFO thresholds (32 entries) */
2922 const unsigned ctrl_xon_thr = 20;
2923 const unsigned ctrl_xoff_thr = 25;
2924 /* RX data FIFO thresholds (256-byte units; size varies) */
2925 unsigned data_xon_thr =
2926 ((rx_xon_thresh_bytes >= 0) ?
2927 rx_xon_thresh_bytes : efx->type->rx_xon_thresh) >> 8;
2928 unsigned data_xoff_thr =
2929 ((rx_xoff_thresh_bytes >= 0) ?
2930 rx_xoff_thresh_bytes : efx->type->rx_xoff_thresh) >> 8;
2931 efx_oword_t reg;
2932
2933 falcon_read(efx, &reg, RX_CFG_REG_KER);
2934 if (falcon_rev(efx) <= FALCON_REV_A1) {
2935 EFX_SET_OWORD_FIELD(reg, RX_DESC_PUSH_EN_A1, 0);
2936 EFX_SET_OWORD_FIELD(reg, RX_USR_BUF_SIZE_A1, huge_buf_size);
2937 EFX_SET_OWORD_FIELD(reg, RX_XON_MAC_TH_A1, data_xon_thr);
2938 EFX_SET_OWORD_FIELD(reg, RX_XOFF_MAC_TH_A1, data_xoff_thr);
2939 EFX_SET_OWORD_FIELD(reg, RX_XON_TX_TH_A1, ctrl_xon_thr);
2940 EFX_SET_OWORD_FIELD(reg, RX_XOFF_TX_TH_A1, ctrl_xoff_thr);
2941 } else {
2942 /* Register fields moved */
2943 EFX_SET_OWORD_FIELD(reg, RX_DESC_PUSH_EN_B0, 0);
2944 EFX_SET_OWORD_FIELD(reg, RX_USR_BUF_SIZE_B0, huge_buf_size);
2945 EFX_SET_OWORD_FIELD(reg, RX_XON_MAC_TH_B0, data_xon_thr);
2946 EFX_SET_OWORD_FIELD(reg, RX_XOFF_MAC_TH_B0, data_xoff_thr);
2947 EFX_SET_OWORD_FIELD(reg, RX_XON_TX_TH_B0, ctrl_xon_thr);
2948 EFX_SET_OWORD_FIELD(reg, RX_XOFF_TX_TH_B0, ctrl_xoff_thr);
2949 EFX_SET_OWORD_FIELD(reg, RX_INGR_EN_B0, 1);
2950 }
2951 falcon_write(efx, &reg, RX_CFG_REG_KER);
2952}
2953
2913/* This call performs hardware-specific global initialisation, such as 2954/* This call performs hardware-specific global initialisation, such as
2914 * defining the descriptor cache sizes and number of RSS channels. 2955 * defining the descriptor cache sizes and number of RSS channels.
2915 * It does not set up any buffers, descriptor rings or event queues. 2956 * It does not set up any buffers, descriptor rings or event queues.
@@ -2917,7 +2958,6 @@ int falcon_probe_nic(struct efx_nic *efx)
2917int falcon_init_nic(struct efx_nic *efx) 2958int falcon_init_nic(struct efx_nic *efx)
2918{ 2959{
2919 efx_oword_t temp; 2960 efx_oword_t temp;
2920 unsigned thresh;
2921 int rc; 2961 int rc;
2922 2962
2923 /* Use on-chip SRAM */ 2963 /* Use on-chip SRAM */
@@ -3024,26 +3064,7 @@ int falcon_init_nic(struct efx_nic *efx)
3024 EFX_SET_OWORD_FIELD(temp, TX_NO_EOP_DISC_EN, 0); 3064 EFX_SET_OWORD_FIELD(temp, TX_NO_EOP_DISC_EN, 0);
3025 falcon_write(efx, &temp, TX_CFG_REG_KER); 3065 falcon_write(efx, &temp, TX_CFG_REG_KER);
3026 3066
3027 /* RX config */ 3067 falcon_init_rx_cfg(efx);
3028 falcon_read(efx, &temp, RX_CFG_REG_KER);
3029 EFX_SET_OWORD_FIELD_VER(efx, temp, RX_DESC_PUSH_EN, 0);
3030 if (EFX_WORKAROUND_7575(efx))
3031 EFX_SET_OWORD_FIELD_VER(efx, temp, RX_USR_BUF_SIZE,
3032 (3 * 4096) / 32);
3033 if (falcon_rev(efx) >= FALCON_REV_B0)
3034 EFX_SET_OWORD_FIELD(temp, RX_INGR_EN_B0, 1);
3035
3036 /* RX FIFO flow control thresholds */
3037 thresh = ((rx_xon_thresh_bytes >= 0) ?
3038 rx_xon_thresh_bytes : efx->type->rx_xon_thresh);
3039 EFX_SET_OWORD_FIELD_VER(efx, temp, RX_XON_MAC_TH, thresh / 256);
3040 thresh = ((rx_xoff_thresh_bytes >= 0) ?
3041 rx_xoff_thresh_bytes : efx->type->rx_xoff_thresh);
3042 EFX_SET_OWORD_FIELD_VER(efx, temp, RX_XOFF_MAC_TH, thresh / 256);
3043 /* RX control FIFO thresholds [32 entries] */
3044 EFX_SET_OWORD_FIELD_VER(efx, temp, RX_XON_TX_TH, 20);
3045 EFX_SET_OWORD_FIELD_VER(efx, temp, RX_XOFF_TX_TH, 25);
3046 falcon_write(efx, &temp, RX_CFG_REG_KER);
3047 3068
3048 /* Set destination of both TX and RX Flush events */ 3069 /* Set destination of both TX and RX Flush events */
3049 if (falcon_rev(efx) >= FALCON_REV_B0) { 3070 if (falcon_rev(efx) >= FALCON_REV_B0) {
diff --git a/drivers/net/sfc/falcon_hwdefs.h b/drivers/net/sfc/falcon_hwdefs.h
index 2d2261117ace..13f3999449f4 100644
--- a/drivers/net/sfc/falcon_hwdefs.h
+++ b/drivers/net/sfc/falcon_hwdefs.h
@@ -313,8 +313,6 @@
313#define RX_XON_MAC_TH_B0_WIDTH 9 313#define RX_XON_MAC_TH_B0_WIDTH 9
314#define RX_XOFF_MAC_TH_B0_LBN 1 314#define RX_XOFF_MAC_TH_B0_LBN 1
315#define RX_XOFF_MAC_TH_B0_WIDTH 9 315#define RX_XOFF_MAC_TH_B0_WIDTH 9
316#define RX_XOFF_MAC_EN_B0_LBN 0
317#define RX_XOFF_MAC_EN_B0_WIDTH 1
318 316
319/* A1 */ 317/* A1 */
320#define RX_DESC_PUSH_EN_A1_LBN 35 318#define RX_DESC_PUSH_EN_A1_LBN 35
@@ -329,8 +327,9 @@
329#define RX_XON_MAC_TH_A1_WIDTH 5 327#define RX_XON_MAC_TH_A1_WIDTH 5
330#define RX_XOFF_MAC_TH_A1_LBN 1 328#define RX_XOFF_MAC_TH_A1_LBN 1
331#define RX_XOFF_MAC_TH_A1_WIDTH 5 329#define RX_XOFF_MAC_TH_A1_WIDTH 5
332#define RX_XOFF_MAC_EN_A1_LBN 0 330
333#define RX_XOFF_MAC_EN_A1_WIDTH 1 331#define RX_XOFF_MAC_EN_LBN 0
332#define RX_XOFF_MAC_EN_WIDTH 1
334 333
335/* Receive filter control register */ 334/* Receive filter control register */
336#define RX_FILTER_CTL_REG 0x810 335#define RX_FILTER_CTL_REG 0x810