Commit b54b8c2d authored by Lada Trimasova's avatar Lada Trimasova Committed by David S. Miller

net: ezchip: adapt driver to little endian architecture

Since ezchip network driver is written with big endian EZChip platform it
is necessary to add support for little endian architecture.

The first issue is that the order of the bits in a bit field is
implementation specific. So all the bit fields are removed.
Named constants are used to access necessary fields.

And the second one is that network byte order is big endian.
For example, data on ethernet is transmitted with most-significant
octet (byte) first. So in case of little endian architecture
it is important to swap data byte order when we read it from
register. In case of unaligned access we can use "get_unaligned_be32"
and in other case we can use function "ioread32_rep" which reads all
data from register and works either with little endian or big endian
architecture.

And then when we are going to write data to register we need to restore
byte order using the function "put_unaligned_be32" in case of
unaligned access and in other case "iowrite32_rep".

The last little fix is a space between type and pointer to observe
coding style.
Signed-off-by: default avatarLada Trimasova <ltrimas@synopsys.com>
Cc: Alexey Brodkin <abrodkin@synopsys.com>
Cc: Noam Camus <noamc@ezchip.com>
Cc: Tal Zilcer <talz@ezchip.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Acked-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 274ba628
This diff is collapsed.
...@@ -43,233 +43,123 @@ ...@@ -43,233 +43,123 @@
#define NPS_ENET_REG_GE_RST 0x1400 #define NPS_ENET_REG_GE_RST 0x1400
#define NPS_ENET_REG_PHASE_FIFO_CTL 0x1404 #define NPS_ENET_REG_PHASE_FIFO_CTL 0x1404
/* Tx control register */ /* Tx control register masks and shifts */
struct nps_enet_tx_ctl { #define TX_CTL_NT_MASK 0x7FF
union { #define TX_CTL_NT_SHIFT 0
/* ct: SW sets to indicate frame ready in Tx buffer for #define TX_CTL_ET_MASK 0x4000
* transmission. HW resets to when transmission done #define TX_CTL_ET_SHIFT 14
* et: Transmit error #define TX_CTL_CT_MASK 0x8000
* nt: Length in bytes of Tx frame loaded to Tx buffer #define TX_CTL_CT_SHIFT 15
*/
struct { /* Rx control register masks and shifts */
u32 #define RX_CTL_NR_MASK 0x7FF
__reserved_1:16, #define RX_CTL_NR_SHIFT 0
ct:1, #define RX_CTL_CRC_MASK 0x2000
et:1, #define RX_CTL_CRC_SHIFT 13
__reserved_2:3, #define RX_CTL_ER_MASK 0x4000
nt:11; #define RX_CTL_ER_SHIFT 14
}; #define RX_CTL_CR_MASK 0x8000
#define RX_CTL_CR_SHIFT 15
u32 value;
}; /* Interrupt enable for data buffer events register masks and shifts */
}; #define RX_RDY_MASK 0x1
#define RX_RDY_SHIFT 0
/* Rx control register */ #define TX_DONE_MASK 0x2
struct nps_enet_rx_ctl { #define TX_DONE_SHIFT 1
union {
/* cr: HW sets to indicate frame ready in Rx buffer. /* Gbps Eth MAC Configuration 0 register masks and shifts */
* SW resets to indicate host read received frame #define CFG_0_RX_EN_MASK 0x1
* and new frames can be written to Rx buffer #define CFG_0_RX_EN_SHIFT 0
* er: Rx error indication #define CFG_0_TX_EN_MASK 0x2
* crc: Rx CRC error indication #define CFG_0_TX_EN_SHIFT 1
* nr: Length in bytes of Rx frame loaded by MAC to Rx buffer #define CFG_0_TX_FC_EN_MASK 0x4
*/ #define CFG_0_TX_FC_EN_SHIFT 2
struct { #define CFG_0_TX_PAD_EN_MASK 0x8
u32 #define CFG_0_TX_PAD_EN_SHIFT 3
__reserved_1:16, #define CFG_0_TX_CRC_EN_MASK 0x10
cr:1, #define CFG_0_TX_CRC_EN_SHIFT 4
er:1, #define CFG_0_RX_FC_EN_MASK 0x20
crc:1, #define CFG_0_RX_FC_EN_SHIFT 5
__reserved_2:2, #define CFG_0_RX_CRC_STRIP_MASK 0x40
nr:11; #define CFG_0_RX_CRC_STRIP_SHIFT 6
}; #define CFG_0_RX_CRC_IGNORE_MASK 0x80
#define CFG_0_RX_CRC_IGNORE_SHIFT 7
u32 value; #define CFG_0_RX_LENGTH_CHECK_EN_MASK 0x100
}; #define CFG_0_RX_LENGTH_CHECK_EN_SHIFT 8
}; #define CFG_0_TX_FC_RETR_MASK 0xE00
#define CFG_0_TX_FC_RETR_SHIFT 9
/* Interrupt enable for data buffer events register */ #define CFG_0_RX_IFG_MASK 0xF000
struct nps_enet_buf_int_enable { #define CFG_0_RX_IFG_SHIFT 12
union { #define CFG_0_TX_IFG_MASK 0x3F0000
/* tx_done: Interrupt generation in the case when new frame #define CFG_0_TX_IFG_SHIFT 16
* is ready in Rx buffer #define CFG_0_RX_PR_CHECK_EN_MASK 0x400000
* rx_rdy: Interrupt generation in the case when current frame #define CFG_0_RX_PR_CHECK_EN_SHIFT 22
* was read from TX buffer #define CFG_0_NIB_MODE_MASK 0x800000
*/ #define CFG_0_NIB_MODE_SHIFT 23
struct { #define CFG_0_TX_IFG_NIB_MASK 0xF000000
u32 #define CFG_0_TX_IFG_NIB_SHIFT 24
__reserved:30, #define CFG_0_TX_PR_LEN_MASK 0xF0000000
tx_done:1, #define CFG_0_TX_PR_LEN_SHIFT 28
rx_rdy:1;
}; /* Gbps Eth MAC Configuration 1 register masks and shifts */
#define CFG_1_OCTET_0_MASK 0x000000FF
u32 value; #define CFG_1_OCTET_0_SHIFT 0
}; #define CFG_1_OCTET_1_MASK 0x0000FF00
}; #define CFG_1_OCTET_1_SHIFT 8
#define CFG_1_OCTET_2_MASK 0x00FF0000
/* Gbps Eth MAC Configuration 0 register */ #define CFG_1_OCTET_2_SHIFT 16
struct nps_enet_ge_mac_cfg_0 { #define CFG_1_OCTET_3_MASK 0xFF000000
union { #define CFG_1_OCTET_3_SHIFT 24
/* tx_pr_len: Transmit preamble length in bytes
* tx_ifg_nib: Tx idle pattern /* Gbps Eth MAC Configuration 2 register masks and shifts */
* nib_mode: Nibble (4-bit) Mode #define CFG_2_OCTET_4_MASK 0x000000FF
* rx_pr_check_en: Receive preamble Check Enable #define CFG_2_OCTET_4_SHIFT 0
* tx_ifg: Transmit inter-Frame Gap #define CFG_2_OCTET_5_MASK 0x0000FF00
* rx_ifg: Receive inter-Frame Gap #define CFG_2_OCTET_5_SHIFT 8
* tx_fc_retr: Transmit Flow Control Retransmit Mode #define CFG_2_DISK_MC_MASK 0x00100000
* rx_length_check_en: Receive Length Check Enable #define CFG_2_DISK_MC_SHIFT 20
* rx_crc_ignore: Results of the CRC check are ignored #define CFG_2_DISK_BC_MASK 0x00200000
* rx_crc_strip: MAC strips the CRC from received frames #define CFG_2_DISK_BC_SHIFT 21
* rx_fc_en: Receive Flow Control Enable #define CFG_2_DISK_DA_MASK 0x00400000
* tx_crc_en: Transmit CRC Enabled #define CFG_2_DISK_DA_SHIFT 22
* tx_pad_en: Transmit Padding Enable #define CFG_2_STAT_EN_MASK 0x3000000
* tx_cf_en: Transmit Flow Control Enable #define CFG_2_STAT_EN_SHIFT 24
* tx_en: Transmit Enable #define CFG_2_TRANSMIT_FLUSH_EN_MASK 0x80000000
* rx_en: Receive Enable #define CFG_2_TRANSMIT_FLUSH_EN_SHIFT 31
*/
struct { /* Gbps Eth MAC Configuration 3 register masks and shifts */
u32 #define CFG_3_TM_HD_MODE_MASK 0x1
tx_pr_len:4, #define CFG_3_TM_HD_MODE_SHIFT 0
tx_ifg_nib:4, #define CFG_3_RX_CBFC_EN_MASK 0x2
nib_mode:1, #define CFG_3_RX_CBFC_EN_SHIFT 1
rx_pr_check_en:1, #define CFG_3_RX_CBFC_REDIR_EN_MASK 0x4
tx_ifg:6, #define CFG_3_RX_CBFC_REDIR_EN_SHIFT 2
rx_ifg:4, #define CFG_3_REDIRECT_CBFC_SEL_MASK 0x18
tx_fc_retr:3, #define CFG_3_REDIRECT_CBFC_SEL_SHIFT 3
rx_length_check_en:1, #define CFG_3_CF_DROP_MASK 0x20
rx_crc_ignore:1, #define CFG_3_CF_DROP_SHIFT 5
rx_crc_strip:1, #define CFG_3_CF_TIMEOUT_MASK 0x3C0
rx_fc_en:1, #define CFG_3_CF_TIMEOUT_SHIFT 6
tx_crc_en:1, #define CFG_3_RX_IFG_TH_MASK 0x7C00
tx_pad_en:1, #define CFG_3_RX_IFG_TH_SHIFT 10
tx_fc_en:1, #define CFG_3_TX_CBFC_EN_MASK 0x8000
tx_en:1, #define CFG_3_TX_CBFC_EN_SHIFT 15
rx_en:1; #define CFG_3_MAX_LEN_MASK 0x3FFF0000
}; #define CFG_3_MAX_LEN_SHIFT 16
#define CFG_3_EXT_OOB_CBFC_SEL_MASK 0xC0000000
u32 value; #define CFG_3_EXT_OOB_CBFC_SEL_SHIFT 30
};
}; /* GE MAC, PCS reset control register masks and shifts */
#define RST_SPCS_MASK 0x1
/* Gbps Eth MAC Configuration 1 register */ #define RST_SPCS_SHIFT 0
struct nps_enet_ge_mac_cfg_1 { #define RST_GMAC_0_MASK 0x100
union { #define RST_GMAC_0_SHIFT 8
/* octet_3: MAC address octet 3
* octet_2: MAC address octet 2 /* Tx phase sync FIFO control register masks and shifts */
* octet_1: MAC address octet 1 #define PHASE_FIFO_CTL_RST_MASK 0x1
* octet_0: MAC address octet 0 #define PHASE_FIFO_CTL_RST_SHIFT 0
*/ #define PHASE_FIFO_CTL_INIT_MASK 0x2
struct { #define PHASE_FIFO_CTL_INIT_SHIFT 1
u32
octet_3:8,
octet_2:8,
octet_1:8,
octet_0:8;
};
u32 value;
};
};
/* Gbps Eth MAC Configuration 2 register */
struct nps_enet_ge_mac_cfg_2 {
union {
/* transmit_flush_en: MAC flush enable
* stat_en: RMON statistics interface enable
* disc_da: Discard frames with DA different
* from MAC address
* disc_bc: Discard broadcast frames
* disc_mc: Discard multicast frames
* octet_5: MAC address octet 5
* octet_4: MAC address octet 4
*/
struct {
u32
transmit_flush_en:1,
__reserved_1:5,
stat_en:2,
__reserved_2:1,
disc_da:1,
disc_bc:1,
disc_mc:1,
__reserved_3:4,
octet_5:8,
octet_4:8;
};
u32 value;
};
};
/* Gbps Eth MAC Configuration 3 register */
struct nps_enet_ge_mac_cfg_3 {
union {
/* ext_oob_cbfc_sel: Selects one of the 4 profiles for
* extended OOB in-flow-control indication
* max_len: Maximum receive frame length in bytes
* tx_cbfc_en: Enable transmission of class-based
* flow control packets
* rx_ifg_th: Threshold for IFG status reporting via OOB
* cf_timeout: Configurable time to decrement FC counters
* cf_drop: Drop control frames
* redirect_cbfc_sel: Selects one of CBFC redirect profiles
* rx_cbfc_redir_en: Enable Rx class-based flow
* control redirect
* rx_cbfc_en: Enable Rx class-based flow control
* tm_hd_mode: TM header mode
*/
struct {
u32
ext_oob_cbfc_sel:2,
max_len:14,
tx_cbfc_en:1,
rx_ifg_th:5,
cf_timeout:4,
cf_drop:1,
redirect_cbfc_sel:2,
rx_cbfc_redir_en:1,
rx_cbfc_en:1,
tm_hd_mode:1;
};
u32 value;
};
};
/* GE MAC, PCS reset control register */
struct nps_enet_ge_rst {
union {
/* gmac_0: GE MAC reset
* spcs_0: SGMII PCS reset
*/
struct {
u32
__reserved_1:23,
gmac_0:1,
__reserved_2:7,
spcs_0:1;
};
u32 value;
};
};
/* Tx phase sync FIFO control register */
struct nps_enet_phase_fifo_ctl {
union {
/* init: initialize serdes TX phase sync FIFO pointers
* rst: reset serdes TX phase sync FIFO
*/
struct {
u32
__reserved:30,
init:1,
rst:1;
};
u32 value;
};
};
/** /**
* struct nps_enet_priv - Storage of ENET's private information. * struct nps_enet_priv - Storage of ENET's private information.
...@@ -285,8 +175,8 @@ struct nps_enet_priv { ...@@ -285,8 +175,8 @@ struct nps_enet_priv {
bool tx_packet_sent; bool tx_packet_sent;
struct sk_buff *tx_skb; struct sk_buff *tx_skb;
struct napi_struct napi; struct napi_struct napi;
struct nps_enet_ge_mac_cfg_2 ge_mac_cfg_2; u32 ge_mac_cfg_2_value;
struct nps_enet_ge_mac_cfg_3 ge_mac_cfg_3; u32 ge_mac_cfg_3_value;
}; };
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment