summaryrefslogtreecommitdiffstats
path: root/drivers/net/e1000
Commit message (Collapse)AuthorAgeFilesLines
* drivers: Make use of device_pci_driver()Andrey Smirnov2019-02-181-6/+1
| | | | | | | Replace all of the generic PCI boilerplate with device_pci_driver(). Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/lseek'Sascha Hauer2019-02-131-2/+0
|\
| * devfs: Drop dev_lseek_default()Andrey Smirnov2019-01-291-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Only the following cdevs do not declare an .lseek() operation: - Console devices in common/console.c - Firmware framework in common/firmware.c - JTAG driver in drivers/misc/jtag.c - UBI in drivers/mtd/ubi/barebox.c Of those four, first two are marked DEVFS_IS_CHARACTER_DEV and implement only .write() operation and the last two don't implement anything but .ioctl(). While there's probably no meaningful way to use lseek() against any of those devices, there doesn't seem to be any harm in allowing it either. Change devfs_lseek() to ignore absense of .lseek() callback and drop dev_lseek_default() and all references to it in the codebase. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | net/e1000: Do not hardcode TDBAH and RDBAH to 0Andrey Smirnov2019-02-111-4/+6
| | | | | | | | | | | | | | | | | | While there currently no user of e1000 driver that places those rings beyond 4GiB boundary, there's also no real reason not to initialize those registers properly. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | net/e1000: Improve RX buffer handling in e1000_fill_rx()Andrey Smirnov2019-02-111-8/+7
| | | | | | | | | | | | | | | | | | Drop explicit "volatile" specifier for struct e1000_rx_desc, "bla" variable as well as explicit endiannes fix, by using little endian IO accessors (readl, writel, etc.) Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | net/e1000: Consolidate next index calculation codeAndrey Smirnov2019-02-111-2/+7
| | | | | | | | | | | | | | | | Consolidate next index calculation code into a helper function and convert the code to make use of it. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | net/e1000: Remove pointer arithmetic from e1000_fill_rx()Andrey Smirnov2019-02-111-2/+1
| | | | | | | | | | | | | | | | | | Instead of relying on reles of pointer arithmetic (implicit multiplication by the size of pointer type), change the code to retreive address of an array elemet to clarify the intent. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | net/e1000: Rename fill_rx() to e1000_fill_rx()Andrey Smirnov2019-02-111-3/+3
| | | | | | | | | | | | | | | | Rename fill_rx() to e1000_fill_rx() to match the naming convention of other functions in the file. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | net/e1000: Make use of readl_poll_timeout() in e1000_transmit()Andrey Smirnov2019-02-111-12/+8
| | | | | | | | | | | | | | Simplify code of e1000_transmit() with readl_poll_timeout(). Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | net/e1000: Improve Tx descriptor handling in e1000_transmitAndrey Smirnov2019-02-111-6/+6
| | | | | | | | | | | | | | | | | | Drop explicit "volatile" specifier for struct e1000_tx_desc as well as explicit endiannes fix, by using little endian IO accessors (readl, writel, etc.) Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | net/e1000: Remove pointer arithmetic in e1000_transmit()Andrey Smirnov2019-02-111-2/+1
| | | | | | | | | | | | | | | | | | Instead of relying on reles of pointer arithmetic (implicit multiplication by the size of pointer type), change the code to retreive address of an array elemet to clarify the intent. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | net/e1000: Improve Rx descriptor handling in e1000_poll()Andrey Smirnov2019-02-111-4/+3
| | | | | | | | | | | | | | | | | | | | | | Drop explicit volatile specifier as well as endianness conversion by changing the code to use appropriate read*() IO accessors. While at it if fix incorrect width used for "status" (8 vs 32) and "len" (16 vs 32). Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | net/e1000: Get rid of pointer arithmetic in e1000_pollAndrey Smirnov2019-02-111-3/+1
| | | | | | | | | | | | | | | | | | Instead of relying on reles of pointer arithmetic (implicit multiplication by the size of pointer type), change the code to retreive address of an array elemet to clarify the intent. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | net/e1000: Fix incorrect "Rx ready" checkAndrey Smirnov2019-02-111-8/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Due to wrong placement of parenthesis in if (!(le32_to_cpu(rd->status)) & E1000_RXD_STAT_DD) return 0; instead of checking that E1000_RXD_STAT_DD is not set, the condition ends up checking that "status" is 0. Change the code to invert the condition tested and get rid of ! entirely. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | net/e1000: Fix debug print warningAndrey Smirnov2019-02-111-1/+2
| | | | | | | | | | | | | | | | Cast eeprom->word_size to int, so it would match its printf specifier to avoid getting errors when building on AArch64. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | net/e1000: Convert e1000_transmit to use dma_map_single()Andrey Smirnov2019-02-111-9/+12
| | | | | | | | | | | | | | | | | | | | Convert e1000_transmit to use dma_map_single()/dma_unmap_single(), which is more apporpirate in this case, since it will account for phys/virtual address difference as well as allow us to check for DMA mapping failure. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | net/e1000: Don't use coherent memory for Rx bufferAndrey Smirnov2019-02-112-4/+15
|/ | | | | | | | | In order to avoid issues on AArch64, convert the driver to use regular memory and add appropriate DMA sync calls. Drop needless (uchar *) cast while at it. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net/e1000: Only read EEPROM_INIT_CONTROL2_REG if it is neededAndrey Smirnov2018-12-171-15/+16
| | | | | | | | | | | | | | E1000_ich8lan, e1000_82573, e1000_82574 and e1000_igb devices (hw->mac_type) do not use data read from EEPROM_INIT_CONTROL2_REG in e1000_setup_link(), so there's no reason for it to bail out when EEPROM read fails. An examlpe use-case would be a i210 adapter initialized from iNVM with no valid EEPROM attached. Change the code to only call e1000_read_eeprom() for devices that do need it. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net/e1000: Use dev_err to report errorAndrey Smirnov2018-12-171-35/+35
| | | | | | | | | | Those messages shouldn't be reported in normal use scenarious and in the case of error using dev_err saves user the trouble of having to run a custom build of Barebox with e1000 debugging enabled to see some initial diagnostic messages. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net/e1000: Do not discard EEPROM error code in e1000_setup_link()Andrey Smirnov2018-12-171-3/+4
| | | | | | | | | E1000_read_eeprom() returns a number of different error codes, so propagate them up the caller chain instead of reducing it to E1000_READ_EEPROM. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net/e1000: Map custom error codes to more appropriate errno valuesAndrey Smirnov2018-12-171-13/+11
| | | | | | | | | | | | | | | | | | | | | | | A number of custom error codes used by e1000 driver will be propagated all the way up to generic networking code and will end up being fed to strerror(). As a result of that, some of the current error codes will result in not very helpful failure messages. For example, trying to ping a host on a system where access to i210's EEPROM fails results in the following message: barebox@ZII RDU2 Board:/ ping 192.168.53.7 ping failed: Operation not permitted In order to make message like that one a little bit more helpful, change definitions of various E1000_ERR_* constants to map to a bit more appropriate error codes. While at it, remove E1000_ERR_MASTER_REQUESTS_PENDING and E1000_ERR_HOST_INTERFACE_COMMAND that are not referenced anywhere in the codebase. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/missing-prototypes'Sascha Hauer2018-12-071-2/+2
|\
| * net/e1000: Mark e1000_register_invm() staticAndrey Smirnov2018-11-191-1/+1
| | | | | | | | | | | | | | | | Mark e1000_register_invm() static because it is not used outside the source file. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * net/e1000: Mark e1000_igb_get_flash_size() staticAndrey Smirnov2018-11-191-1/+1
| | | | | | | | | | | | | | | | Mark e1000_igb_get_flash_size() static because it is not used outside the source file. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | net: e1000: fix "Uninitialized variable: phy_data" warningOleksij Rempel2018-11-211-1/+1
| | | | | | | | | | | | | | | | After carefully reading the code, this situation should never happen. This patch is to reduce warning noise. Signed-off-by: Oleksij Rempel <linux@rempel-privat.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | e1000/flash: Increased erase timeoutMichael Schuhmacher2018-11-121-1/+1
|/ | | | | | | | Serial flash Adesto AT25DF321A specifies the maximal chip erase time as 40 seconds. Extend timeout accordingly. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* drivers: Introduce dev_set_name()Andrey Smirnov2018-10-181-1/+1
| | | | | | | | Introduce dev_set_name() in order to hide implementation details of setting device's name so it'd be easier to change it. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net/e1000: allow to overwrite flash size from device treeUwe Kleine-König2018-07-131-14/+42
| | | | | | | | | | | | | | | | | When barebox probes the e1000 driver and the flash on the i210 device is unprogrammed, the driver assumes the flash has a size of only 4 kiB. This is annoying because to program the flash an image must be written that is bigger than 4 kiB. So you first have to flash the first sector to make barebox detect the right size on the next boot. Then reset the board to be able to write the remaining data. To work around that limitation, try to read the actual size from the device tree. (Note however that barebox' pci code currently doesn't use the device tree and so currently this try always fails without further patching.) Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* rename file_operations -> cdev_operationsSascha Hauer2018-04-061-2/+2
| | | | | | | | Linux also has struct file_operations which are something different. Rename our file_operations to cdev_operations which better matches what we have. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net/e1000: don't register EERPOM device if the content is invalidLucas Stach2018-01-301-17/+24
| | | | | | | | If the EEPROM content isn't valid, there is no point in registering the EEPROM device, as it will reject any read attempt anyway. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net/e1000: don't check EEPROM signature if populated from iNVMLucas Stach2018-01-302-7/+5
| | | | | | | | | | The EEPROM device will contain an invalid signature if it has been populated from iNVM. Since the iNVM enum type has been removed, the only way to tell if a signature check makes sense is to look at the EEPROM valid status. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net/e1000: EEPROM isn't valid if only iNVM is availableLucas Stach2018-01-301-8/+6
| | | | | | | | | | | | | There is no point in registering the emulated EEPROM device if only the iNVM is available with no external flash attached to the i210, as in practice it's only shadowing the iNVM. When the EEPROM is populated from iNVM, the signature is not valid, which causes other parts of the driver to fall over. To fix this just ignore the EEPROM in that case. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net/e1000: use correct bit for flash detectionLucas Stach2018-01-301-1/+1
| | | | | | | Fixes: 95c346ccaa6d (net/e1000: don't access the (simulated) eeprom when it is invalid) Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net/e1000: remove one level of indentationLucas Stach2018-01-301-60/+61
| | | | | | | By returning early if the MAC type isn't e1000_igb. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net/e1000: fix driver probing in the presence of two e1000 devicesUwe Kleine-König2018-01-171-0/+1
| | | | | | | | | | | | | | | | The .id member of the struct device for the invm device is not initialized and so implicitly zero. This yields: register_device: already registered invm0 for the second i210 during probe. So use the parent's id to initialize the id for invm, too, as is already done for the corresponding e1000-nor device. Fixes: a74b97f009c6 ("e1000: Expose i210's iNVM as a cdev") Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net/e1000: indicate at boot time if flash is in secure modeUwe Kleine-König2017-12-062-3/+8
| | | | | | | | If the flash is in secure mode it is not possible to modify its contents. So log that useful information at probe time. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net/e1000: add missing \n in error messageUwe Kleine-König2017-12-011-1/+1
| | | | | Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net/e1000: implement protect and unprotect for attached flashUwe Kleine-König2017-11-282-0/+72
| | | | | | | | | | | | | Some supported flash devices (e.g. SST25VF040) are write protected after power up. If the device holds a valid firmware image the i210 can handle that just fine. If however there is no firmware programmed, a procedure is needed to remove this protection before an image can be flashed. So implement the needed callbacks to make the commands protect and unprotect do the right thing. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net/e1000: expand timeout for flash erasureUwe Kleine-König2017-11-241-1/+1
| | | | | | | | | | | | | | Erasing the whole flash takes approximately 7s on one of my test machines. Expand the timeout accordingly. Note however that it is in general not allowed to hold the flash semaphore for so long and "firmware might implement a timeout mechanism and take ownership of the relevant [lock]" after one second. So a chip erase should better only be done when firmware doesn't make use of the flash. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net/e1000: indicate in error messages where the failure occuredUwe Kleine-König2017-11-241-4/+4
| | | | | | | | | | | | There used to be four places that all emit the same error message. Even if in a given context not all four of them can be relevant, there are always two possible locations where the message can origin from. So make the output slightly different in all places to ease future debugging. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net/e1000: don't access the (simulated) eeprom when it is invalidUwe Kleine-König2017-11-243-6/+35
| | | | | | | | | | The shadow RAM that is used to serve read requests from the eeprom interface isn't valid in all cases. Catch these by returning an error in the eeprom read function and make eeprom validation dependant on working access. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net/e1000: log flash/invm status at probe timeUwe Kleine-König2017-11-241-0/+18
| | | | | | | Provide some info about flash/eeprom state at boot up Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net/e1000: don't fail to bind on uninitialized flashUwe Kleine-König2017-11-241-1/+1
| | | | | | | | | | When the flash doesn't hold a valid firmware image there are still some things (like accessing the flash) possible. Don't return an error code in this case but return 0 instead. This way the driver is regularily bound and just doesn't provide a network interface. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net/e1000: provide device for accessing emulated eepromUwe Kleine-König2017-11-242-1/+44
| | | | | | | | This device uses e1000_read_eeprom to provide access to the emulated eeprom on e1000-igb. Only reading is implemented for now. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net/e1000: fix size of invm deviceUwe Kleine-König2017-11-241-1/+1
| | | | | | | The iNVM storage is 2 Kib containing 64 32bit words (0-63). Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net/e1000: provide access to iNVM even if a flash is presentUwe Kleine-König2017-11-242-67/+72
| | | | | | | | | | | | | | | | | | | An i210 (aka e1000_igb) supports two different non-volatile storages for configuration. There is a built-in one-time programmable storage called iNVM and an optional external SPI-Flash. If a flash is populated and contains a valid configuration image the iNVM is not used (if I understood the documentation correctly). Still the iNVM can be useful if the flash is not configured. Also the iNVM contains manufacturing identification information. So it makes sense to provide the invm device even if a flash is present. This patch also cleans up some confusion that suggests that invm is a way to access the (simulated) eeprom structures and drops some unused enum values. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net/e1000: reorder functionsUwe Kleine-König2017-11-241-70/+67
| | | | | | | | Bring functions in a more natural order which allows to drop a few forward declarations. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net/e1000: don't use the eeprom word size as timeout to get a semaphoreUwe Kleine-König2017-11-241-2/+2
| | | | | | | | | | | | | | Nothing in the documentation suggests that the time to get a semaphore depends on the size of the (optional) eeprom and I doubt there is a relation. Given that 2048 is the maximal value for word_size unless a flash is used to emulate the eeprom, pick 2049 as alternative arbitrary value that probably doesn't result in regressions. This drops the only user of ->word_size outside of eeprom.c which allows easier restructurings there in the future. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net/e1000: fix coding style at a few locationsUwe Kleine-König2017-11-242-5/+14
| | | | | | | | While working on the e1000 driver I noticed a few coding style misdeeds. These are fixed here. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* e1000: Don't poll for FLSWCTL.GLDONE before starting a flash transactionUwe Kleine-König2017-10-161-11/+2
| | | | | | | | | While FLSWCTL.GLDONE is set when the last transaction was fully completed, there is no good reason to depend on this. According to the i210 datasheet having FLSWCTL.DONE is enough. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>