1
2
3
4
5
6
7#ifndef EF4_MDIO_10G_H
8#define EF4_MDIO_10G_H
9
10#include <linux/mdio.h>
11
12
13
14
15
16#include "efx.h"
17
18static inline unsigned ef4_mdio_id_rev(u32 id) { return id & 0xf; }
19static inline unsigned ef4_mdio_id_model(u32 id) { return (id >> 4) & 0x3f; }
20unsigned ef4_mdio_id_oui(u32 id);
21
22static inline int ef4_mdio_read(struct ef4_nic *efx, int devad, int addr)
23{
24 return efx->mdio.mdio_read(efx->net_dev, efx->mdio.prtad, devad, addr);
25}
26
27static inline void
28ef4_mdio_write(struct ef4_nic *efx, int devad, int addr, int value)
29{
30 efx->mdio.mdio_write(efx->net_dev, efx->mdio.prtad, devad, addr, value);
31}
32
33static inline u32 ef4_mdio_read_id(struct ef4_nic *efx, int mmd)
34{
35 u16 id_low = ef4_mdio_read(efx, mmd, MDIO_DEVID2);
36 u16 id_hi = ef4_mdio_read(efx, mmd, MDIO_DEVID1);
37 return (id_hi << 16) | (id_low);
38}
39
40static inline bool ef4_mdio_phyxgxs_lane_sync(struct ef4_nic *efx)
41{
42 int i, lane_status;
43 bool sync;
44
45 for (i = 0; i < 2; ++i)
46 lane_status = ef4_mdio_read(efx, MDIO_MMD_PHYXS,
47 MDIO_PHYXS_LNSTAT);
48
49 sync = !!(lane_status & MDIO_PHYXS_LNSTAT_ALIGN);
50 if (!sync)
51 netif_dbg(efx, hw, efx->net_dev, "XGXS lane status: %x\n",
52 lane_status);
53 return sync;
54}
55
56const char *ef4_mdio_mmd_name(int mmd);
57
58
59
60
61
62
63
64int ef4_mdio_reset_mmd(struct ef4_nic *efx, int mmd, int spins, int spintime);
65
66
67int ef4_mdio_check_mmds(struct ef4_nic *efx, unsigned int mmd_mask);
68
69
70bool ef4_mdio_links_ok(struct ef4_nic *efx, unsigned int mmd_mask);
71
72
73void ef4_mdio_transmit_disable(struct ef4_nic *efx);
74
75
76void ef4_mdio_phy_reconfigure(struct ef4_nic *efx);
77
78
79void ef4_mdio_set_mmds_lpower(struct ef4_nic *efx, int low_power,
80 unsigned int mmd_mask);
81
82
83int ef4_mdio_set_link_ksettings(struct ef4_nic *efx,
84 const struct ethtool_link_ksettings *cmd);
85
86
87void ef4_mdio_an_reconfigure(struct ef4_nic *efx);
88
89
90
91
92u8 ef4_mdio_get_pause(struct ef4_nic *efx);
93
94
95int ef4_mdio_wait_reset_mmds(struct ef4_nic *efx, unsigned int mmd_mask);
96
97
98static inline void
99ef4_mdio_set_flag(struct ef4_nic *efx, int devad, int addr,
100 int mask, bool state)
101{
102 mdio_set_flag(&efx->mdio, efx->mdio.prtad, devad, addr, mask, state);
103}
104
105
106int ef4_mdio_test_alive(struct ef4_nic *efx);
107
108#endif
109