1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright © 2021-2022 Dmitry Salychev
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28 #ifndef _DPAA2_MAC_H
29 #define _DPAA2_MAC_H
30
31 #include <sys/rman.h>
32 #include <sys/bus.h>
33 #include <sys/queue.h>
34
35 #include <net/ethernet.h>
36
37 #include "dpaa2_types.h"
38 #include "dpaa2_mcp.h"
39
40 #define DPAA2_MAC_MAX_RESOURCES 1 /* Maximum resources per DPMAC: 1 DPMCP. */
41 #define DPAA2_MAC_MSI_COUNT 1 /* MSIs per DPMAC */
42
43 /* DPMAC link configuration options. */
44 #define DPAA2_MAC_LINK_OPT_AUTONEG ((uint64_t) 0x01u)
45 #define DPAA2_MAC_LINK_OPT_HALF_DUPLEX ((uint64_t) 0x02u)
46 #define DPAA2_MAC_LINK_OPT_PAUSE ((uint64_t) 0x04u)
47 #define DPAA2_MAC_LINK_OPT_ASYM_PAUSE ((uint64_t) 0x08u)
48
49 enum dpaa2_mac_eth_if {
50 DPAA2_MAC_ETH_IF_MII,
51 DPAA2_MAC_ETH_IF_RMII,
52 DPAA2_MAC_ETH_IF_SMII,
53 DPAA2_MAC_ETH_IF_GMII,
54 DPAA2_MAC_ETH_IF_RGMII,
55 DPAA2_MAC_ETH_IF_SGMII,
56 DPAA2_MAC_ETH_IF_QSGMII,
57 DPAA2_MAC_ETH_IF_XAUI,
58 DPAA2_MAC_ETH_IF_XFI,
59 DPAA2_MAC_ETH_IF_CAUI,
60 DPAA2_MAC_ETH_IF_1000BASEX,
61 DPAA2_MAC_ETH_IF_USXGMII
62 };
63
64 enum dpaa2_mac_link_type {
65 DPAA2_MAC_LINK_TYPE_NONE,
66 DPAA2_MAC_LINK_TYPE_FIXED,
67 DPAA2_MAC_LINK_TYPE_PHY,
68 DPAA2_MAC_LINK_TYPE_BACKPLANE
69 };
70
71 /**
72 * @brief Attributes of the DPMAC object.
73 *
74 * id: DPMAC object ID.
75 * max_rate: Maximum supported rate (in Mbps).
76 * eth_if: Type of the Ethernet interface.
77 * link_type: Type of the link.
78 */
79 struct dpaa2_mac_attr {
80 uint32_t id;
81 uint32_t max_rate;
82 enum dpaa2_mac_eth_if eth_if;
83 enum dpaa2_mac_link_type link_type;
84 };
85
86 /**
87 * @brief Link state of the DPMAC object.
88 */
89 struct dpaa2_mac_link_state {
90 uint64_t options;
91 uint64_t supported;
92 uint64_t advert;
93 uint32_t rate;
94 bool up;
95 bool state_valid;
96 };
97
98 /**
99 * @brief Software context for the DPAA2 MAC driver.
100 *
101 * dev: Device associated with this software context.
102 * addr: Physical address assigned to the DPMAC object.
103 * attr: Attributes of the DPMAC object.
104 */
105 struct dpaa2_mac_softc {
106 device_t dev;
107 uint8_t addr[ETHER_ADDR_LEN];
108 struct resource *res[DPAA2_MAC_MAX_RESOURCES];
109 struct dpaa2_mac_attr attr;
110
111 /* Help to send commands to MC. */
112 struct dpaa2_cmd *cmd;
113 uint16_t rc_token;
114 uint16_t mac_token;
115
116 /* Interrupts. */
117 int irq_rid[DPAA2_MAC_MSI_COUNT];
118 struct resource *irq_res;
119 void *intr; /* interrupt handle */
120 };
121
122 extern struct resource_spec dpaa2_mac_spec[];
123
124 #endif /* _DPAA2_MAC_H */
Cache object: e57a085472b1d90ed504415e0ad4f464
|