18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 10G controller driver for Samsung SoCs 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Copyright (C) 2013 Samsung Electronics Co., Ltd. 58c2ecf20Sopenharmony_ci * http://www.samsung.com 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Author: Siva Reddy Kallam <siva.kallam@samsung.com> 88c2ecf20Sopenharmony_ci */ 98c2ecf20Sopenharmony_ci#ifndef __SXGBE_DESC_H__ 108c2ecf20Sopenharmony_ci#define __SXGBE_DESC_H__ 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#define SXGBE_DESC_SIZE_BYTES 16 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci/* forward declaration */ 158c2ecf20Sopenharmony_cistruct sxgbe_extra_stats; 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci/* Transmit checksum insertion control */ 188c2ecf20Sopenharmony_cienum tdes_csum_insertion { 198c2ecf20Sopenharmony_ci cic_disabled = 0, /* Checksum Insertion Control */ 208c2ecf20Sopenharmony_ci cic_only_ip = 1, /* Only IP header */ 218c2ecf20Sopenharmony_ci /* IP header but pseudoheader is not calculated */ 228c2ecf20Sopenharmony_ci cic_no_pseudoheader = 2, 238c2ecf20Sopenharmony_ci cic_full = 3, /* IP header and pseudoheader */ 248c2ecf20Sopenharmony_ci}; 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_cistruct sxgbe_tx_norm_desc { 278c2ecf20Sopenharmony_ci u64 tdes01; /* buf1 address */ 288c2ecf20Sopenharmony_ci union { 298c2ecf20Sopenharmony_ci /* TX Read-Format Desc 2,3 */ 308c2ecf20Sopenharmony_ci struct { 318c2ecf20Sopenharmony_ci /* TDES2 */ 328c2ecf20Sopenharmony_ci u32 buf1_size:14; 338c2ecf20Sopenharmony_ci u32 vlan_tag_ctl:2; 348c2ecf20Sopenharmony_ci u32 buf2_size:14; 358c2ecf20Sopenharmony_ci u32 timestmp_enable:1; 368c2ecf20Sopenharmony_ci u32 int_on_com:1; 378c2ecf20Sopenharmony_ci /* TDES3 */ 388c2ecf20Sopenharmony_ci union { 398c2ecf20Sopenharmony_ci u16 tcp_payload_len; 408c2ecf20Sopenharmony_ci struct { 418c2ecf20Sopenharmony_ci u32 total_pkt_len:15; 428c2ecf20Sopenharmony_ci u32 reserved1:1; 438c2ecf20Sopenharmony_ci } pkt_len; 448c2ecf20Sopenharmony_ci } tx_pkt_len; 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci u16 cksum_ctl:2; 478c2ecf20Sopenharmony_ci u16 tse_bit:1; 488c2ecf20Sopenharmony_ci u16 tcp_hdr_len:4; 498c2ecf20Sopenharmony_ci u16 sa_insert_ctl:3; 508c2ecf20Sopenharmony_ci u16 crc_pad_ctl:2; 518c2ecf20Sopenharmony_ci u16 last_desc:1; 528c2ecf20Sopenharmony_ci u16 first_desc:1; 538c2ecf20Sopenharmony_ci u16 ctxt_bit:1; 548c2ecf20Sopenharmony_ci u16 own_bit:1; 558c2ecf20Sopenharmony_ci } tx_rd_des23; 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci /* tx write back Desc 2,3 */ 588c2ecf20Sopenharmony_ci struct { 598c2ecf20Sopenharmony_ci /* WB TES2 */ 608c2ecf20Sopenharmony_ci u32 reserved1; 618c2ecf20Sopenharmony_ci /* WB TES3 */ 628c2ecf20Sopenharmony_ci u32 reserved2:31; 638c2ecf20Sopenharmony_ci u32 own_bit:1; 648c2ecf20Sopenharmony_ci } tx_wb_des23; 658c2ecf20Sopenharmony_ci } tdes23; 668c2ecf20Sopenharmony_ci}; 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_cistruct sxgbe_rx_norm_desc { 698c2ecf20Sopenharmony_ci union { 708c2ecf20Sopenharmony_ci u64 rdes01; /* buf1 address */ 718c2ecf20Sopenharmony_ci union { 728c2ecf20Sopenharmony_ci u32 out_vlan_tag:16; 738c2ecf20Sopenharmony_ci u32 in_vlan_tag:16; 748c2ecf20Sopenharmony_ci u32 rss_hash; 758c2ecf20Sopenharmony_ci } rx_wb_des01; 768c2ecf20Sopenharmony_ci } rdes01; 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ci union { 798c2ecf20Sopenharmony_ci /* RX Read format Desc 2,3 */ 808c2ecf20Sopenharmony_ci struct{ 818c2ecf20Sopenharmony_ci /* RDES2 */ 828c2ecf20Sopenharmony_ci u64 buf2_addr:62; 838c2ecf20Sopenharmony_ci /* RDES3 */ 848c2ecf20Sopenharmony_ci u32 int_on_com:1; 858c2ecf20Sopenharmony_ci u32 own_bit:1; 868c2ecf20Sopenharmony_ci } rx_rd_des23; 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci /* RX write back */ 898c2ecf20Sopenharmony_ci struct{ 908c2ecf20Sopenharmony_ci /* WB RDES2 */ 918c2ecf20Sopenharmony_ci u32 hdr_len:10; 928c2ecf20Sopenharmony_ci u32 rdes2_reserved:2; 938c2ecf20Sopenharmony_ci u32 elrd_val:1; 948c2ecf20Sopenharmony_ci u32 iovt_sel:1; 958c2ecf20Sopenharmony_ci u32 res_pkt:1; 968c2ecf20Sopenharmony_ci u32 vlan_filter_match:1; 978c2ecf20Sopenharmony_ci u32 sa_filter_fail:1; 988c2ecf20Sopenharmony_ci u32 da_filter_fail:1; 998c2ecf20Sopenharmony_ci u32 hash_filter_pass:1; 1008c2ecf20Sopenharmony_ci u32 macaddr_filter_match:8; 1018c2ecf20Sopenharmony_ci u32 l3_filter_match:1; 1028c2ecf20Sopenharmony_ci u32 l4_filter_match:1; 1038c2ecf20Sopenharmony_ci u32 l34_filter_num:3; 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_ci /* WB RDES3 */ 1068c2ecf20Sopenharmony_ci u32 pkt_len:14; 1078c2ecf20Sopenharmony_ci u32 rdes3_reserved:1; 1088c2ecf20Sopenharmony_ci u32 err_summary:1; 1098c2ecf20Sopenharmony_ci u32 err_l2_type:4; 1108c2ecf20Sopenharmony_ci u32 layer34_pkt_type:4; 1118c2ecf20Sopenharmony_ci u32 no_coagulation_pkt:1; 1128c2ecf20Sopenharmony_ci u32 in_seq_pkt:1; 1138c2ecf20Sopenharmony_ci u32 rss_valid:1; 1148c2ecf20Sopenharmony_ci u32 context_des_avail:1; 1158c2ecf20Sopenharmony_ci u32 last_desc:1; 1168c2ecf20Sopenharmony_ci u32 first_desc:1; 1178c2ecf20Sopenharmony_ci u32 recv_context_desc:1; 1188c2ecf20Sopenharmony_ci u32 own_bit:1; 1198c2ecf20Sopenharmony_ci } rx_wb_des23; 1208c2ecf20Sopenharmony_ci } rdes23; 1218c2ecf20Sopenharmony_ci}; 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_ci/* Context descriptor structure */ 1248c2ecf20Sopenharmony_cistruct sxgbe_tx_ctxt_desc { 1258c2ecf20Sopenharmony_ci u32 tstamp_lo; 1268c2ecf20Sopenharmony_ci u32 tstamp_hi; 1278c2ecf20Sopenharmony_ci u32 maxseg_size:15; 1288c2ecf20Sopenharmony_ci u32 reserved1:1; 1298c2ecf20Sopenharmony_ci u32 ivlan_tag:16; 1308c2ecf20Sopenharmony_ci u32 vlan_tag:16; 1318c2ecf20Sopenharmony_ci u32 vltag_valid:1; 1328c2ecf20Sopenharmony_ci u32 ivlan_tag_valid:1; 1338c2ecf20Sopenharmony_ci u32 ivlan_tag_ctl:2; 1348c2ecf20Sopenharmony_ci u32 reserved2:3; 1358c2ecf20Sopenharmony_ci u32 ctxt_desc_err:1; 1368c2ecf20Sopenharmony_ci u32 reserved3:2; 1378c2ecf20Sopenharmony_ci u32 ostc:1; 1388c2ecf20Sopenharmony_ci u32 tcmssv:1; 1398c2ecf20Sopenharmony_ci u32 reserved4:2; 1408c2ecf20Sopenharmony_ci u32 ctxt_bit:1; 1418c2ecf20Sopenharmony_ci u32 own_bit:1; 1428c2ecf20Sopenharmony_ci}; 1438c2ecf20Sopenharmony_ci 1448c2ecf20Sopenharmony_cistruct sxgbe_rx_ctxt_desc { 1458c2ecf20Sopenharmony_ci u32 tstamp_lo; 1468c2ecf20Sopenharmony_ci u32 tstamp_hi; 1478c2ecf20Sopenharmony_ci u32 reserved1; 1488c2ecf20Sopenharmony_ci u32 ptp_msgtype:4; 1498c2ecf20Sopenharmony_ci u32 tstamp_available:1; 1508c2ecf20Sopenharmony_ci u32 ptp_rsp_err:1; 1518c2ecf20Sopenharmony_ci u32 tstamp_dropped:1; 1528c2ecf20Sopenharmony_ci u32 reserved2:23; 1538c2ecf20Sopenharmony_ci u32 rx_ctxt_desc:1; 1548c2ecf20Sopenharmony_ci u32 own_bit:1; 1558c2ecf20Sopenharmony_ci}; 1568c2ecf20Sopenharmony_ci 1578c2ecf20Sopenharmony_cistruct sxgbe_desc_ops { 1588c2ecf20Sopenharmony_ci /* DMA TX descriptor ring initialization */ 1598c2ecf20Sopenharmony_ci void (*init_tx_desc)(struct sxgbe_tx_norm_desc *p); 1608c2ecf20Sopenharmony_ci 1618c2ecf20Sopenharmony_ci /* Invoked by the xmit function to prepare the tx descriptor */ 1628c2ecf20Sopenharmony_ci void (*tx_desc_enable_tse)(struct sxgbe_tx_norm_desc *p, u8 is_tse, 1638c2ecf20Sopenharmony_ci u32 total_hdr_len, u32 tcp_hdr_len, 1648c2ecf20Sopenharmony_ci u32 tcp_payload_len); 1658c2ecf20Sopenharmony_ci 1668c2ecf20Sopenharmony_ci /* Assign buffer lengths for descriptor */ 1678c2ecf20Sopenharmony_ci void (*prepare_tx_desc)(struct sxgbe_tx_norm_desc *p, u8 is_fd, 1688c2ecf20Sopenharmony_ci int buf1_len, int pkt_len, int cksum); 1698c2ecf20Sopenharmony_ci 1708c2ecf20Sopenharmony_ci /* Set VLAN control information */ 1718c2ecf20Sopenharmony_ci void (*tx_vlanctl_desc)(struct sxgbe_tx_norm_desc *p, int vlan_ctl); 1728c2ecf20Sopenharmony_ci 1738c2ecf20Sopenharmony_ci /* Set the owner of the descriptor */ 1748c2ecf20Sopenharmony_ci void (*set_tx_owner)(struct sxgbe_tx_norm_desc *p); 1758c2ecf20Sopenharmony_ci 1768c2ecf20Sopenharmony_ci /* Get the owner of the descriptor */ 1778c2ecf20Sopenharmony_ci int (*get_tx_owner)(struct sxgbe_tx_norm_desc *p); 1788c2ecf20Sopenharmony_ci 1798c2ecf20Sopenharmony_ci /* Invoked by the xmit function to close the tx descriptor */ 1808c2ecf20Sopenharmony_ci void (*close_tx_desc)(struct sxgbe_tx_norm_desc *p); 1818c2ecf20Sopenharmony_ci 1828c2ecf20Sopenharmony_ci /* Clean the tx descriptor as soon as the tx irq is received */ 1838c2ecf20Sopenharmony_ci void (*release_tx_desc)(struct sxgbe_tx_norm_desc *p); 1848c2ecf20Sopenharmony_ci 1858c2ecf20Sopenharmony_ci /* Clear interrupt on tx frame completion. When this bit is 1868c2ecf20Sopenharmony_ci * set an interrupt happens as soon as the frame is transmitted 1878c2ecf20Sopenharmony_ci */ 1888c2ecf20Sopenharmony_ci void (*clear_tx_ic)(struct sxgbe_tx_norm_desc *p); 1898c2ecf20Sopenharmony_ci 1908c2ecf20Sopenharmony_ci /* Last tx segment reports the transmit status */ 1918c2ecf20Sopenharmony_ci int (*get_tx_ls)(struct sxgbe_tx_norm_desc *p); 1928c2ecf20Sopenharmony_ci 1938c2ecf20Sopenharmony_ci /* Get the buffer size from the descriptor */ 1948c2ecf20Sopenharmony_ci int (*get_tx_len)(struct sxgbe_tx_norm_desc *p); 1958c2ecf20Sopenharmony_ci 1968c2ecf20Sopenharmony_ci /* Set tx timestamp enable bit */ 1978c2ecf20Sopenharmony_ci void (*tx_enable_tstamp)(struct sxgbe_tx_norm_desc *p); 1988c2ecf20Sopenharmony_ci 1998c2ecf20Sopenharmony_ci /* get tx timestamp status */ 2008c2ecf20Sopenharmony_ci int (*get_tx_timestamp_status)(struct sxgbe_tx_norm_desc *p); 2018c2ecf20Sopenharmony_ci 2028c2ecf20Sopenharmony_ci /* TX Context Descripto Specific */ 2038c2ecf20Sopenharmony_ci void (*tx_ctxt_desc_set_ctxt)(struct sxgbe_tx_ctxt_desc *p); 2048c2ecf20Sopenharmony_ci 2058c2ecf20Sopenharmony_ci /* Set the owner of the TX context descriptor */ 2068c2ecf20Sopenharmony_ci void (*tx_ctxt_desc_set_owner)(struct sxgbe_tx_ctxt_desc *p); 2078c2ecf20Sopenharmony_ci 2088c2ecf20Sopenharmony_ci /* Get the owner of the TX context descriptor */ 2098c2ecf20Sopenharmony_ci int (*get_tx_ctxt_owner)(struct sxgbe_tx_ctxt_desc *p); 2108c2ecf20Sopenharmony_ci 2118c2ecf20Sopenharmony_ci /* Set TX mss */ 2128c2ecf20Sopenharmony_ci void (*tx_ctxt_desc_set_mss)(struct sxgbe_tx_ctxt_desc *p, u16 mss); 2138c2ecf20Sopenharmony_ci 2148c2ecf20Sopenharmony_ci /* Set TX mss */ 2158c2ecf20Sopenharmony_ci int (*tx_ctxt_desc_get_mss)(struct sxgbe_tx_ctxt_desc *p); 2168c2ecf20Sopenharmony_ci 2178c2ecf20Sopenharmony_ci /* Set TX tcmssv */ 2188c2ecf20Sopenharmony_ci void (*tx_ctxt_desc_set_tcmssv)(struct sxgbe_tx_ctxt_desc *p); 2198c2ecf20Sopenharmony_ci 2208c2ecf20Sopenharmony_ci /* Reset TX ostc */ 2218c2ecf20Sopenharmony_ci void (*tx_ctxt_desc_reset_ostc)(struct sxgbe_tx_ctxt_desc *p); 2228c2ecf20Sopenharmony_ci 2238c2ecf20Sopenharmony_ci /* Set IVLAN information */ 2248c2ecf20Sopenharmony_ci void (*tx_ctxt_desc_set_ivlantag)(struct sxgbe_tx_ctxt_desc *p, 2258c2ecf20Sopenharmony_ci int is_ivlanvalid, int ivlan_tag, 2268c2ecf20Sopenharmony_ci int ivlan_ctl); 2278c2ecf20Sopenharmony_ci 2288c2ecf20Sopenharmony_ci /* Return IVLAN Tag */ 2298c2ecf20Sopenharmony_ci int (*tx_ctxt_desc_get_ivlantag)(struct sxgbe_tx_ctxt_desc *p); 2308c2ecf20Sopenharmony_ci 2318c2ecf20Sopenharmony_ci /* Set VLAN Tag */ 2328c2ecf20Sopenharmony_ci void (*tx_ctxt_desc_set_vlantag)(struct sxgbe_tx_ctxt_desc *p, 2338c2ecf20Sopenharmony_ci int is_vlanvalid, int vlan_tag); 2348c2ecf20Sopenharmony_ci 2358c2ecf20Sopenharmony_ci /* Return VLAN Tag */ 2368c2ecf20Sopenharmony_ci int (*tx_ctxt_desc_get_vlantag)(struct sxgbe_tx_ctxt_desc *p); 2378c2ecf20Sopenharmony_ci 2388c2ecf20Sopenharmony_ci /* Set Time stamp */ 2398c2ecf20Sopenharmony_ci void (*tx_ctxt_set_tstamp)(struct sxgbe_tx_ctxt_desc *p, 2408c2ecf20Sopenharmony_ci u8 ostc_enable, u64 tstamp); 2418c2ecf20Sopenharmony_ci 2428c2ecf20Sopenharmony_ci /* Close TX context descriptor */ 2438c2ecf20Sopenharmony_ci void (*close_tx_ctxt_desc)(struct sxgbe_tx_ctxt_desc *p); 2448c2ecf20Sopenharmony_ci 2458c2ecf20Sopenharmony_ci /* WB status of context descriptor */ 2468c2ecf20Sopenharmony_ci int (*get_tx_ctxt_cde)(struct sxgbe_tx_ctxt_desc *p); 2478c2ecf20Sopenharmony_ci 2488c2ecf20Sopenharmony_ci /* DMA RX descriptor ring initialization */ 2498c2ecf20Sopenharmony_ci void (*init_rx_desc)(struct sxgbe_rx_norm_desc *p, int disable_rx_ic, 2508c2ecf20Sopenharmony_ci int mode, int end); 2518c2ecf20Sopenharmony_ci 2528c2ecf20Sopenharmony_ci /* Get own bit */ 2538c2ecf20Sopenharmony_ci int (*get_rx_owner)(struct sxgbe_rx_norm_desc *p); 2548c2ecf20Sopenharmony_ci 2558c2ecf20Sopenharmony_ci /* Set own bit */ 2568c2ecf20Sopenharmony_ci void (*set_rx_owner)(struct sxgbe_rx_norm_desc *p); 2578c2ecf20Sopenharmony_ci 2588c2ecf20Sopenharmony_ci /* Set Interrupt on completion bit */ 2598c2ecf20Sopenharmony_ci void (*set_rx_int_on_com)(struct sxgbe_rx_norm_desc *p); 2608c2ecf20Sopenharmony_ci 2618c2ecf20Sopenharmony_ci /* Get the receive frame size */ 2628c2ecf20Sopenharmony_ci int (*get_rx_frame_len)(struct sxgbe_rx_norm_desc *p); 2638c2ecf20Sopenharmony_ci 2648c2ecf20Sopenharmony_ci /* Return first Descriptor status */ 2658c2ecf20Sopenharmony_ci int (*get_rx_fd_status)(struct sxgbe_rx_norm_desc *p); 2668c2ecf20Sopenharmony_ci 2678c2ecf20Sopenharmony_ci /* Return first Descriptor status */ 2688c2ecf20Sopenharmony_ci int (*get_rx_ld_status)(struct sxgbe_rx_norm_desc *p); 2698c2ecf20Sopenharmony_ci 2708c2ecf20Sopenharmony_ci /* Return the reception status looking at the RDES1 */ 2718c2ecf20Sopenharmony_ci int (*rx_wbstatus)(struct sxgbe_rx_norm_desc *p, 2728c2ecf20Sopenharmony_ci struct sxgbe_extra_stats *x, int *checksum); 2738c2ecf20Sopenharmony_ci 2748c2ecf20Sopenharmony_ci /* Get own bit */ 2758c2ecf20Sopenharmony_ci int (*get_rx_ctxt_owner)(struct sxgbe_rx_ctxt_desc *p); 2768c2ecf20Sopenharmony_ci 2778c2ecf20Sopenharmony_ci /* Set own bit */ 2788c2ecf20Sopenharmony_ci void (*set_rx_ctxt_owner)(struct sxgbe_rx_ctxt_desc *p); 2798c2ecf20Sopenharmony_ci 2808c2ecf20Sopenharmony_ci /* Return the reception status looking at Context control information */ 2818c2ecf20Sopenharmony_ci void (*rx_ctxt_wbstatus)(struct sxgbe_rx_ctxt_desc *p, 2828c2ecf20Sopenharmony_ci struct sxgbe_extra_stats *x); 2838c2ecf20Sopenharmony_ci 2848c2ecf20Sopenharmony_ci /* Get rx timestamp status */ 2858c2ecf20Sopenharmony_ci int (*get_rx_ctxt_tstamp_status)(struct sxgbe_rx_ctxt_desc *p); 2868c2ecf20Sopenharmony_ci 2878c2ecf20Sopenharmony_ci /* Get timestamp value for rx, need to check this */ 2888c2ecf20Sopenharmony_ci u64 (*get_timestamp)(struct sxgbe_rx_ctxt_desc *p); 2898c2ecf20Sopenharmony_ci}; 2908c2ecf20Sopenharmony_ci 2918c2ecf20Sopenharmony_ciconst struct sxgbe_desc_ops *sxgbe_get_desc_ops(void); 2928c2ecf20Sopenharmony_ci 2938c2ecf20Sopenharmony_ci#endif /* __SXGBE_DESC_H__ */ 294