diff options
author | Francois Romieu <romieu@fr.zoreil.com> | 2011-04-26 12:58:59 -0400 |
---|---|---|
committer | Francois romieu <romieu@fr.zoreil.com> | 2011-05-09 15:03:08 -0400 |
commit | 31bd204f97e3796c5cfcfc582a93a10e45b99946 (patch) | |
tree | f405e9e7b0b8c9b34fb6b6ad6e43d49ac586b47e | |
parent | 56de414c0c7333f1e1adedc23057e131ce84233e (diff) |
r8169: provide some firmware information via ethtool.
There is no real firmware version yet but the manpage of ethtool
is rather terse about the driver information.
Former output:
$ ethtool -i eth1
driver: r8169
version: 2.3LK-NAPI
firmware-version:
bus-info: 0000:01:00.0
$ ethtool -i eth0
driver: r8169
version: 2.3LK-NAPI
firmware-version:
bus-info: 0000:03:00.0
Current output:
$ ethtool -i eth1
driver: r8169
version: 2.3LK-NAPI
firmware-version: N/A
bus-info: 0000:01:00.0
$ ethtool -i eth0
driver: r8169
version: 2.3LK-NAPI
firmware-version: rtl_nic/rtl8168d-1.fw
bus-info: 0000:03:00.0
Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
Fixed-by Ciprian Docan <docan@eden.rutgers.edu>
Cc: Realtek linux nic maintainers <nic_swsd@realtek.com>
Cc: Fejes József <fejes@joco.name>
Cc: Borislav Petkov <borislav.petkov@amd.com>
-rw-r--r-- | drivers/net/r8169.c | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c index 81906bc919a4..83e5202d30aa 100644 --- a/drivers/net/r8169.c +++ b/drivers/net/r8169.c | |||
@@ -1188,6 +1188,19 @@ static int rtl8169_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol) | |||
1188 | return 0; | 1188 | return 0; |
1189 | } | 1189 | } |
1190 | 1190 | ||
1191 | static const char *rtl_lookup_firmware_name(struct rtl8169_private *tp) | ||
1192 | { | ||
1193 | int i; | ||
1194 | |||
1195 | for (i = 0; i < ARRAY_SIZE(rtl_firmware_infos); i++) { | ||
1196 | const struct rtl_firmware_info *info = rtl_firmware_infos + i; | ||
1197 | |||
1198 | if (info->mac_version == tp->mac_version) | ||
1199 | return info->fw_name; | ||
1200 | } | ||
1201 | return NULL; | ||
1202 | } | ||
1203 | |||
1191 | static void rtl8169_get_drvinfo(struct net_device *dev, | 1204 | static void rtl8169_get_drvinfo(struct net_device *dev, |
1192 | struct ethtool_drvinfo *info) | 1205 | struct ethtool_drvinfo *info) |
1193 | { | 1206 | { |
@@ -1196,6 +1209,8 @@ static void rtl8169_get_drvinfo(struct net_device *dev, | |||
1196 | strcpy(info->driver, MODULENAME); | 1209 | strcpy(info->driver, MODULENAME); |
1197 | strcpy(info->version, RTL8169_VERSION); | 1210 | strcpy(info->version, RTL8169_VERSION); |
1198 | strcpy(info->bus_info, pci_name(tp->pci_dev)); | 1211 | strcpy(info->bus_info, pci_name(tp->pci_dev)); |
1212 | strncpy(info->fw_version, IS_ERR_OR_NULL(tp->fw) ? "N/A" : | ||
1213 | rtl_lookup_firmware_name(tp), sizeof(info->fw_version) - 1); | ||
1199 | } | 1214 | } |
1200 | 1215 | ||
1201 | static int rtl8169_get_regs_len(struct net_device *dev) | 1216 | static int rtl8169_get_regs_len(struct net_device *dev) |
@@ -3491,33 +3506,23 @@ static void __devexit rtl8169_remove_one(struct pci_dev *pdev) | |||
3491 | 3506 | ||
3492 | static void rtl_request_firmware(struct rtl8169_private *tp) | 3507 | static void rtl_request_firmware(struct rtl8169_private *tp) |
3493 | { | 3508 | { |
3494 | int i; | ||
3495 | |||
3496 | /* Return early if the firmware is already loaded / cached. */ | 3509 | /* Return early if the firmware is already loaded / cached. */ |
3497 | if (!IS_ERR(tp->fw)) | 3510 | if (IS_ERR(tp->fw)) { |
3498 | goto out; | 3511 | const char *name; |
3499 | |||
3500 | for (i = 0; i < ARRAY_SIZE(rtl_firmware_infos); i++) { | ||
3501 | const struct rtl_firmware_info *info = rtl_firmware_infos + i; | ||
3502 | 3512 | ||
3503 | if (info->mac_version == tp->mac_version) { | 3513 | name = rtl_lookup_firmware_name(tp); |
3504 | const char *name = info->fw_name; | 3514 | if (name) { |
3505 | int rc; | 3515 | int rc; |
3506 | 3516 | ||
3507 | rc = request_firmware(&tp->fw, name, &tp->pci_dev->dev); | 3517 | rc = request_firmware(&tp->fw, name, &tp->pci_dev->dev); |
3508 | if (rc < 0) { | 3518 | if (rc >= 0) |
3509 | netif_warn(tp, ifup, tp->dev, "unable to load " | 3519 | return; |
3510 | "firmware patch %s (%d)\n", name, rc); | 3520 | |
3511 | goto out_disable_request_firmware; | 3521 | netif_warn(tp, ifup, tp->dev, "unable to load " |
3512 | } | 3522 | "firmware patch %s (%d)\n", name, rc); |
3513 | goto out; | ||
3514 | } | 3523 | } |
3524 | tp->fw = NULL; | ||
3515 | } | 3525 | } |
3516 | |||
3517 | out_disable_request_firmware: | ||
3518 | tp->fw = NULL; | ||
3519 | out: | ||
3520 | return; | ||
3521 | } | 3526 | } |
3522 | 3527 | ||
3523 | static int rtl8169_open(struct net_device *dev) | 3528 | static int rtl8169_open(struct net_device *dev) |