Aaro Koskinen | 6762098 | 2015-04-04 22:51:21 +0300 | [diff] [blame] | 1 | /* |
| 2 | * This file is based on code from OCTEON SDK by Cavium Networks. |
David Daney | 80ff0fd | 2009-05-05 17:35:21 -0700 | [diff] [blame] | 3 | * |
David Daney | 4898c56 | 2010-02-15 15:06:47 -0800 | [diff] [blame] | 4 | * Copyright (c) 2003-2010 Cavium Networks |
David Daney | 80ff0fd | 2009-05-05 17:35:21 -0700 | [diff] [blame] | 5 | * |
| 6 | * This file is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License, Version 2, as |
| 8 | * published by the Free Software Foundation. |
Aaro Koskinen | 6762098 | 2015-04-04 22:51:21 +0300 | [diff] [blame] | 9 | */ |
David Daney | 80ff0fd | 2009-05-05 17:35:21 -0700 | [diff] [blame] | 10 | |
| 11 | /* |
| 12 | * External interface for the Cavium Octeon ethernet driver. |
| 13 | */ |
| 14 | #ifndef OCTEON_ETHERNET_H |
| 15 | #define OCTEON_ETHERNET_H |
| 16 | |
David Daney | df9244c | 2012-07-05 18:12:40 +0200 | [diff] [blame] | 17 | #include <linux/of.h> |
| 18 | |
Aaro Koskinen | 2638f71 | 2015-04-04 22:51:07 +0300 | [diff] [blame] | 19 | #include <asm/octeon/cvmx-helper-board.h> |
| 20 | |
David Daney | 80ff0fd | 2009-05-05 17:35:21 -0700 | [diff] [blame] | 21 | /** |
| 22 | * This is the definition of the Ethernet driver's private |
| 23 | * driver state stored in netdev_priv(dev). |
| 24 | */ |
| 25 | struct octeon_ethernet { |
| 26 | /* PKO hardware output port */ |
| 27 | int port; |
| 28 | /* PKO hardware queue for the port */ |
| 29 | int queue; |
| 30 | /* Hardware fetch and add to count outstanding tx buffers */ |
| 31 | int fau; |
David Daney | ec3a220 | 2014-05-29 11:10:02 +0100 | [diff] [blame] | 32 | /* My netdev. */ |
| 33 | struct net_device *netdev; |
David Daney | 80ff0fd | 2009-05-05 17:35:21 -0700 | [diff] [blame] | 34 | /* |
| 35 | * Type of port. This is one of the enums in |
| 36 | * cvmx_helper_interface_mode_t |
| 37 | */ |
| 38 | int imode; |
| 39 | /* List of outstanding tx buffers per queue */ |
| 40 | struct sk_buff_head tx_free_list[16]; |
| 41 | /* Device statistics */ |
David Daney | f6ed1b3 | 2009-10-14 12:04:42 -0700 | [diff] [blame] | 42 | struct net_device_stats stats; |
Aaro Koskinen | 710086d | 2016-02-12 01:02:26 +0200 | [diff] [blame] | 43 | unsigned int last_speed; |
David Daney | f6ed1b3 | 2009-10-14 12:04:42 -0700 | [diff] [blame] | 44 | unsigned int last_link; |
David Daney | 80ff0fd | 2009-05-05 17:35:21 -0700 | [diff] [blame] | 45 | /* Last negotiated link state */ |
Aybuke Ozdemir | ec2c398 | 2015-10-01 16:42:16 +0300 | [diff] [blame] | 46 | u64 link_info; |
David Daney | 80ff0fd | 2009-05-05 17:35:21 -0700 | [diff] [blame] | 47 | /* Called periodically to check link status */ |
Aybuke Ozdemir | 3661cdf | 2014-03-16 07:08:46 +0200 | [diff] [blame] | 48 | void (*poll)(struct net_device *dev); |
David Daney | 4898c56 | 2010-02-15 15:06:47 -0800 | [diff] [blame] | 49 | struct delayed_work port_periodic_work; |
David Daney | df9244c | 2012-07-05 18:12:40 +0200 | [diff] [blame] | 50 | struct device_node *of_node; |
David Daney | 80ff0fd | 2009-05-05 17:35:21 -0700 | [diff] [blame] | 51 | }; |
| 52 | |
David Daney | 80ff0fd | 2009-05-05 17:35:21 -0700 | [diff] [blame] | 53 | int cvm_oct_free_work(void *work_queue_entry); |
| 54 | |
Joe Perches | b239904 | 2015-08-10 14:51:26 -0700 | [diff] [blame] | 55 | int cvm_oct_rgmii_open(struct net_device *dev); |
David Daney | f696a10 | 2009-06-23 11:34:08 -0700 | [diff] [blame] | 56 | |
Joe Perches | b239904 | 2015-08-10 14:51:26 -0700 | [diff] [blame] | 57 | int cvm_oct_sgmii_init(struct net_device *dev); |
| 58 | int cvm_oct_sgmii_open(struct net_device *dev); |
David Daney | f696a10 | 2009-06-23 11:34:08 -0700 | [diff] [blame] | 59 | |
Joe Perches | b239904 | 2015-08-10 14:51:26 -0700 | [diff] [blame] | 60 | int cvm_oct_spi_init(struct net_device *dev); |
| 61 | void cvm_oct_spi_uninit(struct net_device *dev); |
David Daney | f696a10 | 2009-06-23 11:34:08 -0700 | [diff] [blame] | 62 | |
Joe Perches | b239904 | 2015-08-10 14:51:26 -0700 | [diff] [blame] | 63 | int cvm_oct_common_init(struct net_device *dev); |
| 64 | void cvm_oct_common_uninit(struct net_device *dev); |
David Daney | ec3a220 | 2014-05-29 11:10:02 +0100 | [diff] [blame] | 65 | void cvm_oct_adjust_link(struct net_device *dev); |
| 66 | int cvm_oct_common_stop(struct net_device *dev); |
Aaro Koskinen | 9e3ae4f | 2015-04-04 22:51:02 +0300 | [diff] [blame] | 67 | int cvm_oct_common_open(struct net_device *dev, |
Aaro Koskinen | 2c265f74 | 2015-10-17 22:28:55 +0300 | [diff] [blame] | 68 | void (*link_poll)(struct net_device *)); |
Aaro Koskinen | 2638f71 | 2015-04-04 22:51:07 +0300 | [diff] [blame] | 69 | void cvm_oct_note_carrier(struct octeon_ethernet *priv, |
| 70 | cvmx_helper_link_info_t li); |
Aaro Koskinen | a8d2e81 | 2015-04-04 22:51:08 +0300 | [diff] [blame] | 71 | void cvm_oct_link_poll(struct net_device *dev); |
David Daney | 80ff0fd | 2009-05-05 17:35:21 -0700 | [diff] [blame] | 72 | |
| 73 | extern int always_use_pow; |
| 74 | extern int pow_send_group; |
Aaro Koskinen | e971a11 | 2016-08-31 23:57:43 +0300 | [diff] [blame] | 75 | extern int pow_receive_groups; |
David Daney | 80ff0fd | 2009-05-05 17:35:21 -0700 | [diff] [blame] | 76 | extern char pow_send_list[]; |
| 77 | extern struct net_device *cvm_oct_device[]; |
David Daney | f8c2648 | 2010-02-15 12:13:17 -0800 | [diff] [blame] | 78 | extern atomic_t cvm_oct_poll_queue_stopping; |
David Daney | 4898c56 | 2010-02-15 15:06:47 -0800 | [diff] [blame] | 79 | extern u64 cvm_oct_tx_poll_interval; |
David Daney | 80ff0fd | 2009-05-05 17:35:21 -0700 | [diff] [blame] | 80 | |
David Daney | 3368c78 | 2010-01-07 11:05:04 -0800 | [diff] [blame] | 81 | extern int rx_napi_weight; |
| 82 | |
David Daney | 80ff0fd | 2009-05-05 17:35:21 -0700 | [diff] [blame] | 83 | #endif |