blob: 9c6852d61c0d3339490241a71e4553357fb3f70b [file] [log] [blame]
Aaro Koskinen67620982015-04-04 22:51:21 +03001/*
2 * This file is based on code from OCTEON SDK by Cavium Networks.
David Daney80ff0fd2009-05-05 17:35:21 -07003 *
David Daney4898c562010-02-15 15:06:47 -08004 * Copyright (c) 2003-2010 Cavium Networks
David Daney80ff0fd2009-05-05 17:35:21 -07005 *
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 Koskinen67620982015-04-04 22:51:21 +03009 */
David Daney80ff0fd2009-05-05 17:35:21 -070010
11/*
12 * External interface for the Cavium Octeon ethernet driver.
13 */
14#ifndef OCTEON_ETHERNET_H
15#define OCTEON_ETHERNET_H
16
David Daneydf9244c2012-07-05 18:12:40 +020017#include <linux/of.h>
18
Aaro Koskinen2638f712015-04-04 22:51:07 +030019#include <asm/octeon/cvmx-helper-board.h>
20
David Daney80ff0fd2009-05-05 17:35:21 -070021/**
22 * This is the definition of the Ethernet driver's private
23 * driver state stored in netdev_priv(dev).
24 */
25struct 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 Daneyec3a2202014-05-29 11:10:02 +010032 /* My netdev. */
33 struct net_device *netdev;
David Daney80ff0fd2009-05-05 17:35:21 -070034 /*
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 Daneyf6ed1b32009-10-14 12:04:42 -070042 struct net_device_stats stats;
Aaro Koskinen710086d2016-02-12 01:02:26 +020043 unsigned int last_speed;
David Daneyf6ed1b32009-10-14 12:04:42 -070044 unsigned int last_link;
David Daney80ff0fd2009-05-05 17:35:21 -070045 /* Last negotiated link state */
Aybuke Ozdemirec2c3982015-10-01 16:42:16 +030046 u64 link_info;
David Daney80ff0fd2009-05-05 17:35:21 -070047 /* Called periodically to check link status */
Aybuke Ozdemir3661cdf2014-03-16 07:08:46 +020048 void (*poll)(struct net_device *dev);
David Daney4898c562010-02-15 15:06:47 -080049 struct delayed_work port_periodic_work;
David Daneydf9244c2012-07-05 18:12:40 +020050 struct device_node *of_node;
David Daney80ff0fd2009-05-05 17:35:21 -070051};
52
David Daney80ff0fd2009-05-05 17:35:21 -070053int cvm_oct_free_work(void *work_queue_entry);
54
Joe Perchesb2399042015-08-10 14:51:26 -070055int cvm_oct_rgmii_open(struct net_device *dev);
David Daneyf696a102009-06-23 11:34:08 -070056
Joe Perchesb2399042015-08-10 14:51:26 -070057int cvm_oct_sgmii_init(struct net_device *dev);
58int cvm_oct_sgmii_open(struct net_device *dev);
David Daneyf696a102009-06-23 11:34:08 -070059
Joe Perchesb2399042015-08-10 14:51:26 -070060int cvm_oct_spi_init(struct net_device *dev);
61void cvm_oct_spi_uninit(struct net_device *dev);
David Daneyf696a102009-06-23 11:34:08 -070062
Joe Perchesb2399042015-08-10 14:51:26 -070063int cvm_oct_common_init(struct net_device *dev);
64void cvm_oct_common_uninit(struct net_device *dev);
David Daneyec3a2202014-05-29 11:10:02 +010065void cvm_oct_adjust_link(struct net_device *dev);
66int cvm_oct_common_stop(struct net_device *dev);
Aaro Koskinen9e3ae4f2015-04-04 22:51:02 +030067int cvm_oct_common_open(struct net_device *dev,
Aaro Koskinen2c265f742015-10-17 22:28:55 +030068 void (*link_poll)(struct net_device *));
Aaro Koskinen2638f712015-04-04 22:51:07 +030069void cvm_oct_note_carrier(struct octeon_ethernet *priv,
70 cvmx_helper_link_info_t li);
Aaro Koskinena8d2e812015-04-04 22:51:08 +030071void cvm_oct_link_poll(struct net_device *dev);
David Daney80ff0fd2009-05-05 17:35:21 -070072
73extern int always_use_pow;
74extern int pow_send_group;
Aaro Koskinene971a112016-08-31 23:57:43 +030075extern int pow_receive_groups;
David Daney80ff0fd2009-05-05 17:35:21 -070076extern char pow_send_list[];
77extern struct net_device *cvm_oct_device[];
David Daneyf8c26482010-02-15 12:13:17 -080078extern atomic_t cvm_oct_poll_queue_stopping;
David Daney4898c562010-02-15 15:06:47 -080079extern u64 cvm_oct_tx_poll_interval;
David Daney80ff0fd2009-05-05 17:35:21 -070080
David Daney3368c782010-01-07 11:05:04 -080081extern int rx_napi_weight;
82
David Daney80ff0fd2009-05-05 17:35:21 -070083#endif