aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/ps3_gelic_net.c81
-rw-r--r--drivers/net/ps3_gelic_net.h20
2 files changed, 101 insertions, 0 deletions
diff --git a/drivers/net/ps3_gelic_net.c b/drivers/net/ps3_gelic_net.c
index 7eb6e7e848f4..e365efb3c627 100644
--- a/drivers/net/ps3_gelic_net.c
+++ b/drivers/net/ps3_gelic_net.c
@@ -1266,6 +1266,85 @@ int gelic_net_set_rx_csum(struct net_device *netdev, u32 data)
1266 return 0; 1266 return 0;
1267} 1267}
1268 1268
1269static void gelic_net_get_wol(struct net_device *netdev,
1270 struct ethtool_wolinfo *wol)
1271{
1272 if (0 <= ps3_compare_firmware_version(2, 2, 0))
1273 wol->supported = WAKE_MAGIC;
1274 else
1275 wol->supported = 0;
1276
1277 wol->wolopts = ps3_sys_manager_get_wol() ? wol->supported : 0;
1278 memset(&wol->sopass, 0, sizeof(wol->sopass));
1279}
1280static int gelic_net_set_wol(struct net_device *netdev,
1281 struct ethtool_wolinfo *wol)
1282{
1283 int status;
1284 struct gelic_card *card;
1285 u64 v1, v2;
1286
1287 if (ps3_compare_firmware_version(2, 2, 0) < 0 ||
1288 !capable(CAP_NET_ADMIN))
1289 return -EPERM;
1290
1291 if (wol->wolopts & ~WAKE_MAGIC)
1292 return -EINVAL;
1293
1294 card = netdev_card(netdev);
1295 if (wol->wolopts & WAKE_MAGIC) {
1296 status = lv1_net_control(bus_id(card), dev_id(card),
1297 GELIC_LV1_SET_WOL,
1298 GELIC_LV1_WOL_MAGIC_PACKET,
1299 0, GELIC_LV1_WOL_MP_ENABLE,
1300 &v1, &v2);
1301 if (status) {
1302 pr_info("%s: enabling WOL failed %d\n", __func__,
1303 status);
1304 status = -EIO;
1305 goto done;
1306 }
1307 status = lv1_net_control(bus_id(card), dev_id(card),
1308 GELIC_LV1_SET_WOL,
1309 GELIC_LV1_WOL_ADD_MATCH_ADDR,
1310 0, GELIC_LV1_WOL_MATCH_ALL,
1311 &v1, &v2);
1312 if (!status)
1313 ps3_sys_manager_set_wol(1);
1314 else {
1315 pr_info("%s: enabling WOL filter failed %d\n",
1316 __func__, status);
1317 status = -EIO;
1318 }
1319 } else {
1320 status = lv1_net_control(bus_id(card), dev_id(card),
1321 GELIC_LV1_SET_WOL,
1322 GELIC_LV1_WOL_MAGIC_PACKET,
1323 0, GELIC_LV1_WOL_MP_DISABLE,
1324 &v1, &v2);
1325 if (status) {
1326 pr_info("%s: disabling WOL failed %d\n", __func__,
1327 status);
1328 status = -EIO;
1329 goto done;
1330 }
1331 status = lv1_net_control(bus_id(card), dev_id(card),
1332 GELIC_LV1_SET_WOL,
1333 GELIC_LV1_WOL_DELETE_MATCH_ADDR,
1334 0, GELIC_LV1_WOL_MATCH_ALL,
1335 &v1, &v2);
1336 if (!status)
1337 ps3_sys_manager_set_wol(0);
1338 else {
1339 pr_info("%s: removing WOL filter failed %d\n",
1340 __func__, status);
1341 status = -EIO;
1342 }
1343 }
1344done:
1345 return status;
1346}
1347
1269static struct ethtool_ops gelic_ether_ethtool_ops = { 1348static struct ethtool_ops gelic_ether_ethtool_ops = {
1270 .get_drvinfo = gelic_net_get_drvinfo, 1349 .get_drvinfo = gelic_net_get_drvinfo,
1271 .get_settings = gelic_ether_get_settings, 1350 .get_settings = gelic_ether_get_settings,
@@ -1274,6 +1353,8 @@ static struct ethtool_ops gelic_ether_ethtool_ops = {
1274 .set_tx_csum = ethtool_op_set_tx_csum, 1353 .set_tx_csum = ethtool_op_set_tx_csum,
1275 .get_rx_csum = gelic_net_get_rx_csum, 1354 .get_rx_csum = gelic_net_get_rx_csum,
1276 .set_rx_csum = gelic_net_set_rx_csum, 1355 .set_rx_csum = gelic_net_set_rx_csum,
1356 .get_wol = gelic_net_get_wol,
1357 .set_wol = gelic_net_set_wol,
1277}; 1358};
1278 1359
1279/** 1360/**
diff --git a/drivers/net/ps3_gelic_net.h b/drivers/net/ps3_gelic_net.h
index 1d39d06797e4..520f143c2c09 100644
--- a/drivers/net/ps3_gelic_net.h
+++ b/drivers/net/ps3_gelic_net.h
@@ -182,12 +182,32 @@ enum gelic_lv1_net_control_code {
182 GELIC_LV1_GET_ETH_PORT_STATUS = 2, 182 GELIC_LV1_GET_ETH_PORT_STATUS = 2,
183 GELIC_LV1_SET_NEGOTIATION_MODE = 3, 183 GELIC_LV1_SET_NEGOTIATION_MODE = 3,
184 GELIC_LV1_GET_VLAN_ID = 4, 184 GELIC_LV1_GET_VLAN_ID = 4,
185 GELIC_LV1_SET_WOL = 5,
185 GELIC_LV1_GET_CHANNEL = 6, 186 GELIC_LV1_GET_CHANNEL = 6,
186 GELIC_LV1_POST_WLAN_CMD = 9, 187 GELIC_LV1_POST_WLAN_CMD = 9,
187 GELIC_LV1_GET_WLAN_CMD_RESULT = 10, 188 GELIC_LV1_GET_WLAN_CMD_RESULT = 10,
188 GELIC_LV1_GET_WLAN_EVENT = 11 189 GELIC_LV1_GET_WLAN_EVENT = 11
189}; 190};
190 191
192/* for GELIC_LV1_SET_WOL */
193enum gelic_lv1_wol_command {
194 GELIC_LV1_WOL_MAGIC_PACKET = 1,
195 GELIC_LV1_WOL_ADD_MATCH_ADDR = 6,
196 GELIC_LV1_WOL_DELETE_MATCH_ADDR = 7,
197};
198
199/* for GELIC_LV1_WOL_MAGIC_PACKET */
200enum gelic_lv1_wol_mp_arg {
201 GELIC_LV1_WOL_MP_DISABLE = 0,
202 GELIC_LV1_WOL_MP_ENABLE = 1,
203};
204
205/* for GELIC_LV1_WOL_{ADD,DELETE}_MATCH_ADDR */
206enum gelic_lv1_wol_match_arg {
207 GELIC_LV1_WOL_MATCH_INDIVIDUAL = 0,
208 GELIC_LV1_WOL_MATCH_ALL = 1,
209};
210
191/* status returened from GET_ETH_PORT_STATUS */ 211/* status returened from GET_ETH_PORT_STATUS */
192enum gelic_lv1_ether_port_status { 212enum gelic_lv1_ether_port_status {
193 GELIC_LV1_ETHER_LINK_UP = 0x0000000000000001L, 213 GELIC_LV1_ETHER_LINK_UP = 0x0000000000000001L,