Jose Abreu | 42de047 | 2018-04-16 16:08:12 +0100 | [diff] [blame^] | 1 | // SPDX-License-Identifier: (GPL-2.0 OR MIT) |
| 2 | // Copyright (c) 2018 Synopsys, Inc. and/or its affiliates. |
| 3 | // stmmac HW Interface Callbacks |
| 4 | |
| 5 | #ifndef __STMMAC_HWIF_H__ |
| 6 | #define __STMMAC_HWIF_H__ |
| 7 | |
| 8 | #define stmmac_do_void_callback(__priv, __module, __cname, __arg0, __args...) \ |
| 9 | ({ \ |
| 10 | int __result = -EINVAL; \ |
| 11 | if ((__priv)->hw->__module->__cname) { \ |
| 12 | (__priv)->hw->__module->__cname((__arg0), ##__args); \ |
| 13 | __result = 0; \ |
| 14 | } \ |
| 15 | __result; \ |
| 16 | }) |
| 17 | #define stmmac_do_callback(__priv, __module, __cname, __arg0, __args...) \ |
| 18 | ({ \ |
| 19 | int __result = -EINVAL; \ |
| 20 | if ((__priv)->hw->__module->__cname) \ |
| 21 | __result = (__priv)->hw->__module->__cname((__arg0), ##__args); \ |
| 22 | __result; \ |
| 23 | }) |
| 24 | |
| 25 | struct stmmac_extra_stats; |
| 26 | struct stmmac_safety_stats; |
| 27 | struct dma_desc; |
| 28 | struct dma_extended_desc; |
| 29 | |
| 30 | /* Descriptors helpers */ |
| 31 | struct stmmac_desc_ops { |
| 32 | /* DMA RX descriptor ring initialization */ |
| 33 | void (*init_rx_desc)(struct dma_desc *p, int disable_rx_ic, int mode, |
| 34 | int end); |
| 35 | /* DMA TX descriptor ring initialization */ |
| 36 | void (*init_tx_desc)(struct dma_desc *p, int mode, int end); |
| 37 | /* Invoked by the xmit function to prepare the tx descriptor */ |
| 38 | void (*prepare_tx_desc)(struct dma_desc *p, int is_fs, int len, |
| 39 | bool csum_flag, int mode, bool tx_own, bool ls, |
| 40 | unsigned int tot_pkt_len); |
| 41 | void (*prepare_tso_tx_desc)(struct dma_desc *p, int is_fs, int len1, |
| 42 | int len2, bool tx_own, bool ls, unsigned int tcphdrlen, |
| 43 | unsigned int tcppayloadlen); |
| 44 | /* Set/get the owner of the descriptor */ |
| 45 | void (*set_tx_owner)(struct dma_desc *p); |
| 46 | int (*get_tx_owner)(struct dma_desc *p); |
| 47 | /* Clean the tx descriptor as soon as the tx irq is received */ |
| 48 | void (*release_tx_desc)(struct dma_desc *p, int mode); |
| 49 | /* Clear interrupt on tx frame completion. When this bit is |
| 50 | * set an interrupt happens as soon as the frame is transmitted */ |
| 51 | void (*set_tx_ic)(struct dma_desc *p); |
| 52 | /* Last tx segment reports the transmit status */ |
| 53 | int (*get_tx_ls)(struct dma_desc *p); |
| 54 | /* Return the transmit status looking at the TDES1 */ |
| 55 | int (*tx_status)(void *data, struct stmmac_extra_stats *x, |
| 56 | struct dma_desc *p, void __iomem *ioaddr); |
| 57 | /* Get the buffer size from the descriptor */ |
| 58 | int (*get_tx_len)(struct dma_desc *p); |
| 59 | /* Handle extra events on specific interrupts hw dependent */ |
| 60 | void (*set_rx_owner)(struct dma_desc *p); |
| 61 | /* Get the receive frame size */ |
| 62 | int (*get_rx_frame_len)(struct dma_desc *p, int rx_coe_type); |
| 63 | /* Return the reception status looking at the RDES1 */ |
| 64 | int (*rx_status)(void *data, struct stmmac_extra_stats *x, |
| 65 | struct dma_desc *p); |
| 66 | void (*rx_extended_status)(void *data, struct stmmac_extra_stats *x, |
| 67 | struct dma_extended_desc *p); |
| 68 | /* Set tx timestamp enable bit */ |
| 69 | void (*enable_tx_timestamp) (struct dma_desc *p); |
| 70 | /* get tx timestamp status */ |
| 71 | int (*get_tx_timestamp_status) (struct dma_desc *p); |
| 72 | /* get timestamp value */ |
| 73 | void (*get_timestamp)(void *desc, u32 ats, u64 *ts); |
| 74 | /* get rx timestamp status */ |
| 75 | int (*get_rx_timestamp_status)(void *desc, void *next_desc, u32 ats); |
| 76 | /* Display ring */ |
| 77 | void (*display_ring)(void *head, unsigned int size, bool rx); |
| 78 | /* set MSS via context descriptor */ |
| 79 | void (*set_mss)(struct dma_desc *p, unsigned int mss); |
| 80 | }; |
| 81 | |
| 82 | #define stmmac_init_rx_desc(__priv, __args...) \ |
| 83 | stmmac_do_void_callback(__priv, desc, init_rx_desc, __args) |
| 84 | #define stmmac_init_tx_desc(__priv, __args...) \ |
| 85 | stmmac_do_void_callback(__priv, desc, init_tx_desc, __args) |
| 86 | #define stmmac_prepare_tx_desc(__priv, __args...) \ |
| 87 | stmmac_do_void_callback(__priv, desc, prepare_tx_desc, __args) |
| 88 | #define stmmac_prepare_tso_tx_desc(__priv, __args...) \ |
| 89 | stmmac_do_void_callback(__priv, desc, prepare_tso_tx_desc, __args) |
| 90 | #define stmmac_set_tx_owner(__priv, __args...) \ |
| 91 | stmmac_do_void_callback(__priv, desc, set_tx_owner, __args) |
| 92 | #define stmmac_get_tx_owner(__priv, __args...) \ |
| 93 | stmmac_do_callback(__priv, desc, get_tx_owner, __args) |
| 94 | #define stmmac_release_tx_desc(__priv, __args...) \ |
| 95 | stmmac_do_void_callback(__priv, desc, release_tx_desc, __args) |
| 96 | #define stmmac_set_tx_ic(__priv, __args...) \ |
| 97 | stmmac_do_void_callback(__priv, desc, set_tx_ic, __args) |
| 98 | #define stmmac_get_tx_ls(__priv, __args...) \ |
| 99 | stmmac_do_callback(__priv, desc, get_tx_ls, __args) |
| 100 | #define stmmac_tx_status(__priv, __args...) \ |
| 101 | stmmac_do_callback(__priv, desc, tx_status, __args) |
| 102 | #define stmmac_get_tx_len(__priv, __args...) \ |
| 103 | stmmac_do_callback(__priv, desc, get_tx_len, __args) |
| 104 | #define stmmac_set_rx_owner(__priv, __args...) \ |
| 105 | stmmac_do_void_callback(__priv, desc, set_rx_owner, __args) |
| 106 | #define stmmac_get_rx_frame_len(__priv, __args...) \ |
| 107 | stmmac_do_callback(__priv, desc, get_rx_frame_len, __args) |
| 108 | #define stmmac_rx_status(__priv, __args...) \ |
| 109 | stmmac_do_callback(__priv, desc, rx_status, __args) |
| 110 | #define stmmac_rx_extended_status(__priv, __args...) \ |
| 111 | stmmac_do_void_callback(__priv, desc, rx_extended_status, __args) |
| 112 | #define stmmac_enable_tx_timestamp(__priv, __args...) \ |
| 113 | stmmac_do_void_callback(__priv, desc, enable_tx_timestamp, __args) |
| 114 | #define stmmac_get_tx_timestamp_status(__priv, __args...) \ |
| 115 | stmmac_do_callback(__priv, desc, get_tx_timestamp_status, __args) |
| 116 | #define stmmac_get_timestamp(__priv, __args...) \ |
| 117 | stmmac_do_void_callback(__priv, desc, get_timestamp, __args) |
| 118 | #define stmmac_get_rx_timestamp_status(__priv, __args...) \ |
| 119 | stmmac_do_callback(__priv, desc, get_rx_timestamp_status, __args) |
| 120 | #define stmmac_display_ring(__priv, __args...) \ |
| 121 | stmmac_do_void_callback(__priv, desc, display_ring, __args) |
| 122 | #define stmmac_set_mss(__priv, __args...) \ |
| 123 | stmmac_do_void_callback(__priv, desc, set_mss, __args) |
| 124 | |
| 125 | #endif /* __STMMAC_HWIF_H__ */ |