Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/1251/?format=api
{ "id": 1251, "url": "http://patchwork.ozlabs.org/api/patches/1251/?format=api", "web_url": "http://patchwork.ozlabs.org/project/netdev/patch/48D9FE65.40709@redhat.com/", "project": { "id": 7, "url": "http://patchwork.ozlabs.org/api/projects/7/?format=api", "name": "Linux network development", "link_name": "netdev", "list_id": "netdev.vger.kernel.org", "list_email": "netdev@vger.kernel.org", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<48D9FE65.40709@redhat.com>", "list_archive_url": null, "date": "2008-09-24T08:46:29", "name": "r8169: read MAC address from EEPROM on init", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": true, "hash": "1966fe44e5dd763b08ef252ea47a4abc92759a76", "submitter": { "id": 262, "url": "http://patchwork.ozlabs.org/api/people/262/?format=api", "name": "Ivan Vecera", "email": "ivecera@redhat.com" }, "delegate": { "id": 36, "url": "http://patchwork.ozlabs.org/api/users/36/?format=api", "username": "jgarzik", "first_name": "Jeff", "last_name": "Garzik", "email": "jgarzik@pobox.com" }, "mbox": "http://patchwork.ozlabs.org/project/netdev/patch/48D9FE65.40709@redhat.com/mbox/", "series": [], "comments": "http://patchwork.ozlabs.org/api/patches/1251/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/1251/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<netdev-owner@vger.kernel.org>", "X-Original-To": "patchwork-incoming@ozlabs.org", "Delivered-To": "patchwork-incoming@ozlabs.org", "Received": [ "from vger.kernel.org (vger.kernel.org [209.132.176.167])\n\tby ozlabs.org (Postfix) with ESMTP id 0F121DDE00\n\tfor <patchwork-incoming@ozlabs.org>;\n\tWed, 24 Sep 2008 18:47:35 +1000 (EST)", "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751573AbYIXIr3 (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tWed, 24 Sep 2008 04:47:29 -0400", "(majordomo@vger.kernel.org) by vger.kernel.org id S1751615AbYIXIr3\n\t(ORCPT <rfc822; netdev-outgoing>); Wed, 24 Sep 2008 04:47:29 -0400", "from mx2.redhat.com ([66.187.237.31]:53917 \"EHLO mx2.redhat.com\"\n\trhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP\n\tid S1751573AbYIXIr2 (ORCPT <rfc822;netdev@vger.kernel.org>);\n\tWed, 24 Sep 2008 04:47:28 -0400", "from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com\n\t[172.16.27.26])\n\tby mx2.redhat.com (8.13.8/8.13.8) with ESMTP id m8O8lGbS005636;\n\tWed, 24 Sep 2008 04:47:17 -0400", "from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199])\n\tby int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id\n\tm8O8lF7d028791; Wed, 24 Sep 2008 04:47:16 -0400", "from [10.34.32.182] (cera.englab.brq.redhat.com [10.34.32.182])\n\tby ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id m8O8lC8b018271;\n\tWed, 24 Sep 2008 04:47:13 -0400" ], "Message-ID": "<48D9FE65.40709@redhat.com>", "Date": "Wed, 24 Sep 2008 10:46:29 +0200", "From": "Ivan Vecera <ivecera@redhat.com>", "User-Agent": "Thunderbird 2.0.0.16 (X11/20080724)", "MIME-Version": "1.0", "To": "=?ISO-8859-1?Q?Ilpo_J=E4rvinen?= <ilpo.jarvinen@helsinki.fi>,\n\tFrancois Romieu <romieu@fr.zoreil.com>", "CC": "Netdev <netdev@vger.kernel.org>, Edward Hsu <edward_hsu@realtek.com.tw>", "Subject": "Re: [PATCH] r8169: read MAC address from EEPROM on init", "References": "<48D25BA2.6070008@redhat.com>\n\t<Pine.LNX.4.64.0809182235550.4742@wrl-59.cs.helsinki.fi>\n\t<48D3A381.1080500@redhat.com>\n\t<Pine.LNX.4.64.0809210100020.16838@wrl-59.cs.helsinki.fi>", "In-Reply-To": "<Pine.LNX.4.64.0809210100020.16838@wrl-59.cs.helsinki.fi>", "X-Enigmail-Version": "0.95.0", "Content-Type": "text/plain; charset=ISO-8859-1", "Content-Transfer-Encoding": "8bit", "X-Scanned-By": "MIMEDefang 2.58 on 172.16.27.26", "Sender": "netdev-owner@vger.kernel.org", "Precedence": "bulk", "List-ID": "<netdev.vger.kernel.org>", "X-Mailing-List": "netdev@vger.kernel.org" }, "content": "Ilpo Järvinen wrote:\n> Aa, one more thing here, there's nowadays print_mac() and \n> DECLARE_MAC_BUF() for printing MAC-addresses using %s. Since this is \n> not perf-critical in anyway here, it will save some bytes when used in \n> kernel-wide scale.\n> \n> \n> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi>\nOK :-), I hope the patch below is finally the right one.\n\nIvan\n\n---\n drivers/net/r8169.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++-\n 1 files changed, 72 insertions(+), 1 deletions(-)", "diff": "diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c\nindex befc927..e979cf5 100644\n--- a/drivers/net/r8169.c\n+++ b/drivers/net/r8169.c\n@@ -1910,6 +1910,74 @@ static void rtl_disable_msi(struct pci_dev *pdev, struct rtl8169_private *tp)\n \t}\n }\n\n+static int rtl_eeprom_read(struct pci_dev *pdev, int cap, int addr, __le32 *val)\n+{\n+\tint ret, count = 100;\n+\tu16 status = 0;\n+\tu32 value;\n+\n+\tret = pci_write_config_word(pdev, cap + PCI_VPD_ADDR, addr);\n+\tif (ret < 0)\n+\t\treturn ret;\n+\n+\tdo {\n+\t\tudelay(10);\n+\t\tret = pci_read_config_word(pdev, cap + PCI_VPD_ADDR, &status);\n+\t\tif (ret < 0)\n+\t\t\treturn ret;\n+\t} while (!(status & PCI_VPD_ADDR_F) && --count);\n+\n+\tif (!(status & PCI_VPD_ADDR_F))\n+\t\treturn -ETIMEDOUT;\n+\n+\tret = pci_read_config_dword(pdev, cap + PCI_VPD_DATA, &value);\n+\tif (ret < 0)\n+\t\treturn ret;\n+\n+\t*val = cpu_to_le32(value);\n+\n+\treturn 0;\n+}\n+\n+static void rtl_init_mac_address(struct rtl8169_private *tp,\n+\t\t\t\t void __iomem *ioaddr)\n+{\n+\tstruct pci_dev *pdev = tp->pci_dev;\n+\tu8 cfg1;\n+\tint vpd_cap;\n+\tu8 mac[8];\n+\tDECLARE_MAC_BUF(buf);\n+\n+\tcfg1 = RTL_R8(Config1);\n+\tif (!(cfg1 & VPD)) {\n+\t\tdprintk(\"VPD access not enabled, enabling\\n\");\n+\t\tRTL_W8(Cfg9346, Cfg9346_Unlock);\n+\t\tRTL_W8(Config1, cfg1 | VPD);\n+\t\tRTL_W8(Cfg9346, Cfg9346_Lock);\n+\t}\n+\n+\tvpd_cap = pci_find_capability(pdev, PCI_CAP_ID_VPD);\n+\tif (!vpd_cap)\n+\t\treturn;\n+\n+\t/* MAC address is stored in EEPROM at offset 0x0e\n+\t * Realtek says: \"The VPD address does not have to be a DWORD-aligned\n+\t * address as defined in the PCI 2.2 Specifications, but the VPD data\n+\t * is always consecutive 4-byte data starting from the VPD address\n+\t * specified.\"\n+\t */\n+\tif (rtl_eeprom_read(pdev, vpd_cap, 0x000e, (__le32*)&mac[0]) < 0 ||\n+\t rtl_eeprom_read(pdev, vpd_cap, 0x0012, (__le32*)&mac[4]) < 0) {\n+\t\tdprintk(\"Reading MAC address from EEPROM failed\\n\");\n+\t\treturn;\n+\t}\n+\n+\tdprintk(\"MAC address found in EEPROM: %s\\n\", print_mac(buf, mac));\n+\n+\t/* Write MAC address */\n+\trtl_rar_set(tp, mac);\n+}\n+\n static int __devinit\n rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)\n {\n@@ -2079,7 +2147,10 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)\n \t\tdev->do_ioctl = rtl8169_ioctl;\n \t}\n\n-\t/* Get MAC address. FIXME: read EEPROM */\n+\t/* Read MAC address from EEPROM */\n+\trtl_init_mac_address(tp, ioaddr);\n+\n+\t/* Get MAC address */\n \tfor (i = 0; i < MAC_ADDR_LEN; i++)\n \t\tdev->dev_addr[i] = RTL_R8(MAC0 + i);\n \tmemcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);\n", "prefixes": [] }