| .. | .. |
|---|
| 12 | 12 | static struct { |
|---|
| 13 | 13 | enum dpsw_counter id; |
|---|
| 14 | 14 | char name[ETH_GSTRING_LEN]; |
|---|
| 15 | | -} ethsw_ethtool_counters[] = { |
|---|
| 15 | +} dpaa2_switch_ethtool_counters[] = { |
|---|
| 16 | 16 | {DPSW_CNT_ING_FRAME, "rx frames"}, |
|---|
| 17 | 17 | {DPSW_CNT_ING_BYTE, "rx bytes"}, |
|---|
| 18 | 18 | {DPSW_CNT_ING_FLTR_FRAME, "rx filtered frames"}, |
|---|
| .. | .. |
|---|
| 27 | 27 | |
|---|
| 28 | 28 | }; |
|---|
| 29 | 29 | |
|---|
| 30 | | -#define ETHSW_NUM_COUNTERS ARRAY_SIZE(ethsw_ethtool_counters) |
|---|
| 30 | +#define DPAA2_SWITCH_NUM_COUNTERS ARRAY_SIZE(dpaa2_switch_ethtool_counters) |
|---|
| 31 | 31 | |
|---|
| 32 | | -static void ethsw_get_drvinfo(struct net_device *netdev, |
|---|
| 33 | | - struct ethtool_drvinfo *drvinfo) |
|---|
| 32 | +static void dpaa2_switch_get_drvinfo(struct net_device *netdev, |
|---|
| 33 | + struct ethtool_drvinfo *drvinfo) |
|---|
| 34 | 34 | { |
|---|
| 35 | 35 | struct ethsw_port_priv *port_priv = netdev_priv(netdev); |
|---|
| 36 | 36 | u16 version_major, version_minor; |
|---|
| .. | .. |
|---|
| 53 | 53 | } |
|---|
| 54 | 54 | |
|---|
| 55 | 55 | static int |
|---|
| 56 | | -ethsw_get_link_ksettings(struct net_device *netdev, |
|---|
| 57 | | - struct ethtool_link_ksettings *link_ksettings) |
|---|
| 56 | +dpaa2_switch_get_link_ksettings(struct net_device *netdev, |
|---|
| 57 | + struct ethtool_link_ksettings *link_ksettings) |
|---|
| 58 | 58 | { |
|---|
| 59 | 59 | struct ethsw_port_priv *port_priv = netdev_priv(netdev); |
|---|
| 60 | 60 | struct dpsw_link_state state = {0}; |
|---|
| .. | .. |
|---|
| 65 | 65 | port_priv->idx, |
|---|
| 66 | 66 | &state); |
|---|
| 67 | 67 | if (err) { |
|---|
| 68 | | - netdev_err(netdev, "ERROR %d getting link state", err); |
|---|
| 68 | + netdev_err(netdev, "ERROR %d getting link state\n", err); |
|---|
| 69 | 69 | goto out; |
|---|
| 70 | 70 | } |
|---|
| 71 | 71 | |
|---|
| .. | .. |
|---|
| 84 | 84 | } |
|---|
| 85 | 85 | |
|---|
| 86 | 86 | static int |
|---|
| 87 | | -ethsw_set_link_ksettings(struct net_device *netdev, |
|---|
| 88 | | - const struct ethtool_link_ksettings *link_ksettings) |
|---|
| 87 | +dpaa2_switch_set_link_ksettings(struct net_device *netdev, |
|---|
| 88 | + const struct ethtool_link_ksettings *link_ksettings) |
|---|
| 89 | 89 | { |
|---|
| 90 | 90 | struct ethsw_port_priv *port_priv = netdev_priv(netdev); |
|---|
| 91 | + struct ethsw_core *ethsw = port_priv->ethsw_data; |
|---|
| 91 | 92 | struct dpsw_link_cfg cfg = {0}; |
|---|
| 92 | | - int err = 0; |
|---|
| 93 | + bool if_running; |
|---|
| 94 | + int err = 0, ret; |
|---|
| 93 | 95 | |
|---|
| 94 | | - netdev_dbg(netdev, "Setting link parameters..."); |
|---|
| 95 | | - |
|---|
| 96 | | - /* Due to a temporary MC limitation, the DPSW port must be down |
|---|
| 97 | | - * in order to be able to change link settings. Taking steps to let |
|---|
| 98 | | - * the user know that. |
|---|
| 99 | | - */ |
|---|
| 100 | | - if (netif_running(netdev)) { |
|---|
| 101 | | - netdev_info(netdev, "Sorry, interface must be brought down first.\n"); |
|---|
| 102 | | - return -EACCES; |
|---|
| 96 | + /* Interface needs to be down to change link settings */ |
|---|
| 97 | + if_running = netif_running(netdev); |
|---|
| 98 | + if (if_running) { |
|---|
| 99 | + err = dpsw_if_disable(ethsw->mc_io, 0, |
|---|
| 100 | + ethsw->dpsw_handle, |
|---|
| 101 | + port_priv->idx); |
|---|
| 102 | + if (err) { |
|---|
| 103 | + netdev_err(netdev, "dpsw_if_disable err %d\n", err); |
|---|
| 104 | + return err; |
|---|
| 105 | + } |
|---|
| 103 | 106 | } |
|---|
| 104 | 107 | |
|---|
| 105 | 108 | cfg.rate = link_ksettings->base.speed; |
|---|
| .. | .. |
|---|
| 116 | 119 | port_priv->ethsw_data->dpsw_handle, |
|---|
| 117 | 120 | port_priv->idx, |
|---|
| 118 | 121 | &cfg); |
|---|
| 119 | | - if (err) |
|---|
| 120 | | - /* ethtool will be loud enough if we return an error; no point |
|---|
| 121 | | - * in putting our own error message on the console by default |
|---|
| 122 | | - */ |
|---|
| 123 | | - netdev_dbg(netdev, "ERROR %d setting link cfg", err); |
|---|
| 124 | 122 | |
|---|
| 123 | + if (if_running) { |
|---|
| 124 | + ret = dpsw_if_enable(ethsw->mc_io, 0, |
|---|
| 125 | + ethsw->dpsw_handle, |
|---|
| 126 | + port_priv->idx); |
|---|
| 127 | + if (ret) { |
|---|
| 128 | + netdev_err(netdev, "dpsw_if_enable err %d\n", ret); |
|---|
| 129 | + return ret; |
|---|
| 130 | + } |
|---|
| 131 | + } |
|---|
| 125 | 132 | return err; |
|---|
| 126 | 133 | } |
|---|
| 127 | 134 | |
|---|
| 128 | | -static int ethsw_ethtool_get_sset_count(struct net_device *dev, int sset) |
|---|
| 135 | +static int dpaa2_switch_ethtool_get_sset_count(struct net_device *dev, int sset) |
|---|
| 129 | 136 | { |
|---|
| 130 | 137 | switch (sset) { |
|---|
| 131 | 138 | case ETH_SS_STATS: |
|---|
| 132 | | - return ETHSW_NUM_COUNTERS; |
|---|
| 139 | + return DPAA2_SWITCH_NUM_COUNTERS; |
|---|
| 133 | 140 | default: |
|---|
| 134 | 141 | return -EOPNOTSUPP; |
|---|
| 135 | 142 | } |
|---|
| 136 | 143 | } |
|---|
| 137 | 144 | |
|---|
| 138 | | -static void ethsw_ethtool_get_strings(struct net_device *netdev, |
|---|
| 139 | | - u32 stringset, u8 *data) |
|---|
| 145 | +static void dpaa2_switch_ethtool_get_strings(struct net_device *netdev, |
|---|
| 146 | + u32 stringset, u8 *data) |
|---|
| 140 | 147 | { |
|---|
| 141 | 148 | int i; |
|---|
| 142 | 149 | |
|---|
| 143 | 150 | switch (stringset) { |
|---|
| 144 | 151 | case ETH_SS_STATS: |
|---|
| 145 | | - for (i = 0; i < ETHSW_NUM_COUNTERS; i++) |
|---|
| 152 | + for (i = 0; i < DPAA2_SWITCH_NUM_COUNTERS; i++) |
|---|
| 146 | 153 | memcpy(data + i * ETH_GSTRING_LEN, |
|---|
| 147 | | - ethsw_ethtool_counters[i].name, ETH_GSTRING_LEN); |
|---|
| 154 | + dpaa2_switch_ethtool_counters[i].name, |
|---|
| 155 | + ETH_GSTRING_LEN); |
|---|
| 148 | 156 | break; |
|---|
| 149 | 157 | } |
|---|
| 150 | 158 | } |
|---|
| 151 | 159 | |
|---|
| 152 | | -static void ethsw_ethtool_get_stats(struct net_device *netdev, |
|---|
| 153 | | - struct ethtool_stats *stats, |
|---|
| 154 | | - u64 *data) |
|---|
| 160 | +static void dpaa2_switch_ethtool_get_stats(struct net_device *netdev, |
|---|
| 161 | + struct ethtool_stats *stats, |
|---|
| 162 | + u64 *data) |
|---|
| 155 | 163 | { |
|---|
| 156 | 164 | struct ethsw_port_priv *port_priv = netdev_priv(netdev); |
|---|
| 157 | 165 | int i, err; |
|---|
| 158 | 166 | |
|---|
| 159 | | - memset(data, 0, |
|---|
| 160 | | - sizeof(u64) * ETHSW_NUM_COUNTERS); |
|---|
| 161 | | - |
|---|
| 162 | | - for (i = 0; i < ETHSW_NUM_COUNTERS; i++) { |
|---|
| 167 | + for (i = 0; i < DPAA2_SWITCH_NUM_COUNTERS; i++) { |
|---|
| 163 | 168 | err = dpsw_if_get_counter(port_priv->ethsw_data->mc_io, 0, |
|---|
| 164 | 169 | port_priv->ethsw_data->dpsw_handle, |
|---|
| 165 | 170 | port_priv->idx, |
|---|
| 166 | | - ethsw_ethtool_counters[i].id, |
|---|
| 171 | + dpaa2_switch_ethtool_counters[i].id, |
|---|
| 167 | 172 | &data[i]); |
|---|
| 168 | 173 | if (err) |
|---|
| 169 | 174 | netdev_err(netdev, "dpsw_if_get_counter[%s] err %d\n", |
|---|
| 170 | | - ethsw_ethtool_counters[i].name, err); |
|---|
| 175 | + dpaa2_switch_ethtool_counters[i].name, err); |
|---|
| 171 | 176 | } |
|---|
| 172 | 177 | } |
|---|
| 173 | 178 | |
|---|
| 174 | | -const struct ethtool_ops ethsw_port_ethtool_ops = { |
|---|
| 175 | | - .get_drvinfo = ethsw_get_drvinfo, |
|---|
| 179 | +const struct ethtool_ops dpaa2_switch_port_ethtool_ops = { |
|---|
| 180 | + .get_drvinfo = dpaa2_switch_get_drvinfo, |
|---|
| 176 | 181 | .get_link = ethtool_op_get_link, |
|---|
| 177 | | - .get_link_ksettings = ethsw_get_link_ksettings, |
|---|
| 178 | | - .set_link_ksettings = ethsw_set_link_ksettings, |
|---|
| 179 | | - .get_strings = ethsw_ethtool_get_strings, |
|---|
| 180 | | - .get_ethtool_stats = ethsw_ethtool_get_stats, |
|---|
| 181 | | - .get_sset_count = ethsw_ethtool_get_sset_count, |
|---|
| 182 | + .get_link_ksettings = dpaa2_switch_get_link_ksettings, |
|---|
| 183 | + .set_link_ksettings = dpaa2_switch_set_link_ksettings, |
|---|
| 184 | + .get_strings = dpaa2_switch_ethtool_get_strings, |
|---|
| 185 | + .get_ethtool_stats = dpaa2_switch_ethtool_get_stats, |
|---|
| 186 | + .get_sset_count = dpaa2_switch_ethtool_get_sset_count, |
|---|
| 182 | 187 | }; |
|---|