Commit 56fff0a0 authored by David S. Miller's avatar David S. Miller

Merge branch 'fjes'

Taku Izumi says:

====================
FUJITSU Extended Socket network device driver

This patchsets adds FUJITSU Extended Socket network device driver.
Extended Socket network device is a shared memory based high-speed
network interface between Extended Partitions of PRIMEQUEST 2000 E2
series.

You can get some information about Extended Partition and Extended
Socket by referring the following manual.

http://globalsp.ts.fujitsu.com/dmsp/Publications/public/CA92344-0537.pdf
    3.2.1 Extended Partitioning
    3.2.2 Extended Socke

v2.2 -> v3:
   - Fix up according to David's comment (No functional change)
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 4a89ba04 786eec27
......@@ -413,6 +413,13 @@ config VMXNET3
To compile this driver as a module, choose M here: the
module will be called vmxnet3.
config FUJITSU_ES
tristate "FUJITSU Extended Socket Network Device driver"
depends on ACPI
help
This driver provides support for Extended Socket network device
on Extended Partitioning of FUJITSU PRIMEQUEST 2000 E2 series.
source "drivers/net/hyperv/Kconfig"
endif # NETDEVICES
......@@ -68,3 +68,5 @@ obj-$(CONFIG_USB_NET_DRIVERS) += usb/
obj-$(CONFIG_HYPERV_NET) += hyperv/
obj-$(CONFIG_NTB_NETDEV) += ntb_netdev.o
obj-$(CONFIG_FUJITSU_ES) += fjes/
################################################################################
#
# FUJITSU Extended Socket Network Device driver
# Copyright (c) 2015 FUJITSU LIMITED
#
# This program is free software; you can redistribute it and/or modify it
# under the terms and conditions of the GNU General Public License,
# version 2, as published by the Free Software Foundation.
#
# This program is distributed in the hope it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, see <http://www.gnu.org/licenses/>.
#
# The full GNU General Public License is included in this distribution in
# the file called "COPYING".
#
################################################################################
#
# Makefile for the FUJITSU Extended Socket network device driver
#
obj-$(CONFIG_FUJITSU_ES) += fjes.o
fjes-objs := fjes_main.o fjes_hw.o fjes_ethtool.o
/*
* FUJITSU Extended Socket Network Device driver
* Copyright (c) 2015 FUJITSU LIMITED
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see <http://www.gnu.org/licenses/>.
*
* The full GNU General Public License is included in this distribution in
* the file called "COPYING".
*
*/
#ifndef FJES_H_
#define FJES_H_
#include <linux/acpi.h>
#include "fjes_hw.h"
#define FJES_ACPI_SYMBOL "Extended Socket"
#define FJES_MAX_QUEUES 1
#define FJES_TX_RETRY_INTERVAL (20 * HZ)
#define FJES_TX_RETRY_TIMEOUT (100)
#define FJES_TX_TX_STALL_TIMEOUT (FJES_TX_RETRY_INTERVAL / 2)
#define FJES_OPEN_ZONE_UPDATE_WAIT (300) /* msec */
#define FJES_IRQ_WATCH_DELAY (HZ)
/* board specific private data structure */
struct fjes_adapter {
struct net_device *netdev;
struct platform_device *plat_dev;
struct napi_struct napi;
struct rtnl_link_stats64 stats64;
unsigned int tx_retry_count;
unsigned long tx_start_jiffies;
unsigned long rx_last_jiffies;
bool unset_rx_last;
struct work_struct force_close_task;
bool force_reset;
bool open_guard;
bool irq_registered;
struct workqueue_struct *txrx_wq;
struct workqueue_struct *control_wq;
struct work_struct tx_stall_task;
struct work_struct raise_intr_rxdata_task;
struct work_struct unshare_watch_task;
unsigned long unshare_watch_bitmask;
struct delayed_work interrupt_watch_task;
bool interrupt_watch_enable;
struct fjes_hw hw;
};
extern char fjes_driver_name[];
extern char fjes_driver_version[];
extern const u32 fjes_support_mtu[];
void fjes_set_ethtool_ops(struct net_device *);
#endif /* FJES_H_ */
/*
* FUJITSU Extended Socket Network Device driver
* Copyright (c) 2015 FUJITSU LIMITED
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see <http://www.gnu.org/licenses/>.
*
* The full GNU General Public License is included in this distribution in
* the file called "COPYING".
*
*/
/* ethtool support for fjes */
#include <linux/vmalloc.h>
#include <linux/netdevice.h>
#include <linux/ethtool.h>
#include <linux/platform_device.h>
#include "fjes.h"
struct fjes_stats {
char stat_string[ETH_GSTRING_LEN];
int sizeof_stat;
int stat_offset;
};
#define FJES_STAT(name, stat) { \
.stat_string = name, \
.sizeof_stat = FIELD_SIZEOF(struct fjes_adapter, stat), \
.stat_offset = offsetof(struct fjes_adapter, stat) \
}
static const struct fjes_stats fjes_gstrings_stats[] = {
FJES_STAT("rx_packets", stats64.rx_packets),
FJES_STAT("tx_packets", stats64.tx_packets),
FJES_STAT("rx_bytes", stats64.rx_bytes),
FJES_STAT("tx_bytes", stats64.rx_bytes),
FJES_STAT("rx_dropped", stats64.rx_dropped),
FJES_STAT("tx_dropped", stats64.tx_dropped),
};
static void fjes_get_ethtool_stats(struct net_device *netdev,
struct ethtool_stats *stats, u64 *data)
{
struct fjes_adapter *adapter = netdev_priv(netdev);
char *p;
int i;
for (i = 0; i < ARRAY_SIZE(fjes_gstrings_stats); i++) {
p = (char *)adapter + fjes_gstrings_stats[i].stat_offset;
data[i] = (fjes_gstrings_stats[i].sizeof_stat == sizeof(u64))
? *(u64 *)p : *(u32 *)p;
}
}
static void fjes_get_strings(struct net_device *netdev,
u32 stringset, u8 *data)
{
u8 *p = data;
int i;
switch (stringset) {
case ETH_SS_STATS:
for (i = 0; i < ARRAY_SIZE(fjes_gstrings_stats); i++) {
memcpy(p, fjes_gstrings_stats[i].stat_string,
ETH_GSTRING_LEN);
p += ETH_GSTRING_LEN;
}
break;
}
}
static int fjes_get_sset_count(struct net_device *netdev, int sset)
{
switch (sset) {
case ETH_SS_STATS:
return ARRAY_SIZE(fjes_gstrings_stats);
default:
return -EOPNOTSUPP;
}
}
static void fjes_get_drvinfo(struct net_device *netdev,
struct ethtool_drvinfo *drvinfo)
{
struct fjes_adapter *adapter = netdev_priv(netdev);
struct platform_device *plat_dev;
plat_dev = adapter->plat_dev;
strlcpy(drvinfo->driver, fjes_driver_name, sizeof(drvinfo->driver));
strlcpy(drvinfo->version, fjes_driver_version,
sizeof(drvinfo->version));
strlcpy(drvinfo->fw_version, "none", sizeof(drvinfo->fw_version));
snprintf(drvinfo->bus_info, sizeof(drvinfo->bus_info),
"platform:%s", plat_dev->name);
drvinfo->regdump_len = 0;
drvinfo->eedump_len = 0;
}
static int fjes_get_settings(struct net_device *netdev,
struct ethtool_cmd *ecmd)
{
ecmd->supported = 0;
ecmd->advertising = 0;
ecmd->duplex = DUPLEX_FULL;
ecmd->autoneg = AUTONEG_DISABLE;
ecmd->transceiver = XCVR_DUMMY1;
ecmd->port = PORT_NONE;
ethtool_cmd_speed_set(ecmd, 20000); /* 20Gb/s */
return 0;
}
static const struct ethtool_ops fjes_ethtool_ops = {
.get_settings = fjes_get_settings,
.get_drvinfo = fjes_get_drvinfo,
.get_ethtool_stats = fjes_get_ethtool_stats,
.get_strings = fjes_get_strings,
.get_sset_count = fjes_get_sset_count,
};
void fjes_set_ethtool_ops(struct net_device *netdev)
{
netdev->ethtool_ops = &fjes_ethtool_ops;
}
This diff is collapsed.
/*
* FUJITSU Extended Socket Network Device driver
* Copyright (c) 2015 FUJITSU LIMITED
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see <http://www.gnu.org/licenses/>.
*
* The full GNU General Public License is included in this distribution in
* the file called "COPYING".
*
*/
#ifndef FJES_HW_H_
#define FJES_HW_H_
#include <linux/netdevice.h>
#include <linux/if_vlan.h>
#include <linux/vmalloc.h>
#include "fjes_regs.h"
struct fjes_hw;
#define EP_BUFFER_SUPPORT_VLAN_MAX 4
#define EP_BUFFER_INFO_SIZE 4096
#define FJES_DEVICE_RESET_TIMEOUT ((17 + 1) * 3) /* sec */
#define FJES_COMMAND_REQ_TIMEOUT (5 + 1) /* sec */
#define FJES_COMMAND_REQ_BUFF_TIMEOUT (8 * 3) /* sec */
#define FJES_COMMAND_EPSTOP_WAIT_TIMEOUT (1) /* sec */
#define FJES_CMD_REQ_ERR_INFO_PARAM (0x0001)
#define FJES_CMD_REQ_ERR_INFO_STATUS (0x0002)
#define FJES_CMD_REQ_RES_CODE_NORMAL (0)
#define FJES_CMD_REQ_RES_CODE_BUSY (1)
#define FJES_ZONING_STATUS_DISABLE (0x00)
#define FJES_ZONING_STATUS_ENABLE (0x01)
#define FJES_ZONING_STATUS_INVALID (0xFF)
#define FJES_ZONING_ZONE_TYPE_NONE (0xFF)
#define FJES_TX_DELAY_SEND_NONE (0)
#define FJES_TX_DELAY_SEND_PENDING (1)
#define FJES_RX_STOP_REQ_NONE (0x0)
#define FJES_RX_STOP_REQ_DONE (0x1)
#define FJES_RX_STOP_REQ_REQUEST (0x2)
#define FJES_RX_POLL_WORK (0x4)
#define EP_BUFFER_SIZE \
(((sizeof(union ep_buffer_info) + (128 * (64 * 1024))) \
/ EP_BUFFER_INFO_SIZE) * EP_BUFFER_INFO_SIZE)
#define EP_RING_NUM(buffer_size, frame_size) \
(u32)((buffer_size) / (frame_size))
#define EP_RING_INDEX(_num, _max) (((_num) + (_max)) % (_max))
#define EP_RING_INDEX_INC(_num, _max) \
((_num) = EP_RING_INDEX((_num) + 1, (_max)))
#define EP_RING_FULL(_head, _tail, _max) \
(0 == EP_RING_INDEX(((_tail) - (_head)), (_max)))
#define EP_RING_EMPTY(_head, _tail, _max) \
(1 == EP_RING_INDEX(((_tail) - (_head)), (_max)))
#define FJES_MTU_TO_BUFFER_SIZE(mtu) \
(ETH_HLEN + VLAN_HLEN + (mtu) + ETH_FCS_LEN)
#define FJES_MTU_TO_FRAME_SIZE(mtu) \
(sizeof(struct esmem_frame) + FJES_MTU_TO_BUFFER_SIZE(mtu))
#define FJES_MTU_DEFINE(size) \
((size) - sizeof(struct esmem_frame) - \
(ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN))
#define FJES_DEV_COMMAND_INFO_REQ_LEN (4)
#define FJES_DEV_COMMAND_INFO_RES_LEN(epnum) (8 + 2 * (epnum))
#define FJES_DEV_COMMAND_SHARE_BUFFER_REQ_LEN(txb, rxb) \
(24 + (8 * ((txb) / EP_BUFFER_INFO_SIZE + (rxb) / EP_BUFFER_INFO_SIZE)))
#define FJES_DEV_COMMAND_SHARE_BUFFER_RES_LEN (8)
#define FJES_DEV_COMMAND_UNSHARE_BUFFER_REQ_LEN (8)
#define FJES_DEV_COMMAND_UNSHARE_BUFFER_RES_LEN (8)
#define FJES_DEV_REQ_BUF_SIZE(maxep) \
FJES_DEV_COMMAND_SHARE_BUFFER_REQ_LEN(EP_BUFFER_SIZE, EP_BUFFER_SIZE)
#define FJES_DEV_RES_BUF_SIZE(maxep) \
FJES_DEV_COMMAND_INFO_RES_LEN(maxep)
/* Frame & MTU */
struct esmem_frame {
__le32 frame_size;
u8 frame_data[];
};
/* EP partner status */
enum ep_partner_status {
EP_PARTNER_UNSHARE,
EP_PARTNER_SHARED,
EP_PARTNER_WAITING,
EP_PARTNER_COMPLETE,
EP_PARTNER_STATUS_MAX,
};
/* shared status region */
struct fjes_device_shared_info {
int epnum;
u8 ep_status[];
};
/* structures for command control request data*/
union fjes_device_command_req {
struct {
__le32 length;
} info;
struct {
__le32 length;
__le32 epid;
__le64 buffer[];
} share_buffer;
struct {
__le32 length;
__le32 epid;
} unshare_buffer;
struct {
__le32 length;
__le32 mode;
__le64 buffer_len;
__le64 buffer[];
} start_trace;
struct {
__le32 length;
} stop_trace;
};
/* structures for command control response data */
union fjes_device_command_res {
struct {
__le32 length;
__le32 code;
struct {
u8 es_status;
u8 zone;
} info[];
} info;
struct {
__le32 length;
__le32 code;
} share_buffer;
struct {
__le32 length;
__le32 code;
} unshare_buffer;
struct {
__le32 length;
__le32 code;
} start_trace;
struct {
__le32 length;
__le32 code;
} stop_trace;
};
/* request command type */
enum fjes_dev_command_request_type {
FJES_CMD_REQ_INFO = 0x0001,
FJES_CMD_REQ_SHARE_BUFFER = 0x0002,
FJES_CMD_REQ_UNSHARE_BUFFER = 0x0004,
};
/* parameter for command control */
struct fjes_device_command_param {
u32 req_len;
phys_addr_t req_start;
u32 res_len;
phys_addr_t res_start;
phys_addr_t share_start;
};
/* error code for command control */
enum fjes_dev_command_response_e {
FJES_CMD_STATUS_UNKNOWN,
FJES_CMD_STATUS_NORMAL,
FJES_CMD_STATUS_TIMEOUT,
FJES_CMD_STATUS_ERROR_PARAM,
FJES_CMD_STATUS_ERROR_STATUS,
};
/* EP buffer information */
union ep_buffer_info {
u8 raw[EP_BUFFER_INFO_SIZE];
struct _ep_buffer_info_common_t {
u32 version;
} common;
struct _ep_buffer_info_v1_t {
u32 version;
u32 info_size;
u32 buffer_size;
u16 count_max;
u16 _rsv_1;
u32 frame_max;
u8 mac_addr[ETH_ALEN];
u16 _rsv_2;
u32 _rsv_3;
u16 tx_status;
u16 rx_status;
u32 head;
u32 tail;
u16 vlan_id[EP_BUFFER_SUPPORT_VLAN_MAX];
} v1i;
};
/* buffer pair for Extended Partition */
struct ep_share_mem_info {
struct epbuf_handler {
void *buffer;
size_t size;
union ep_buffer_info *info;
u8 *ring;
} tx, rx;
struct rtnl_link_stats64 net_stats;
u16 tx_status_work;
u8 es_status;
u8 zone;
};
struct es_device_trace {
u32 record_num;
u32 current_record;
u32 status_flag;
u32 _rsv;
struct {
u16 epid;
u16 dir_offset;
u32 data;
u64 tsc;
} record[];
};
struct fjes_hw_info {
struct fjes_device_shared_info *share;
union fjes_device_command_req *req_buf;
u64 req_buf_size;
union fjes_device_command_res *res_buf;
u64 res_buf_size;
int *my_epid;
int *max_epid;
struct es_device_trace *trace;
u64 trace_size;
struct mutex lock; /* buffer lock*/
unsigned long buffer_share_bit;
unsigned long buffer_unshare_reserve_bit;
};
struct fjes_hw {
void *back;
unsigned long txrx_stop_req_bit;
unsigned long epstop_req_bit;
struct work_struct update_zone_task;
struct work_struct epstop_task;
int my_epid;
int max_epid;
struct ep_share_mem_info *ep_shm_info;
struct fjes_hw_resource {
u64 start;
u64 size;
int irq;
} hw_res;
u8 *base;
struct fjes_hw_info hw_info;
};
int fjes_hw_init(struct fjes_hw *);
void fjes_hw_exit(struct fjes_hw *);
int fjes_hw_reset(struct fjes_hw *);
int fjes_hw_request_info(struct fjes_hw *);
int fjes_hw_register_buff_addr(struct fjes_hw *, int,
struct ep_share_mem_info *);
int fjes_hw_unregister_buff_addr(struct fjes_hw *, int);
void fjes_hw_init_command_registers(struct fjes_hw *,
struct fjes_device_command_param *);
void fjes_hw_setup_epbuf(struct epbuf_handler *, u8 *, u32);
int fjes_hw_raise_interrupt(struct fjes_hw *, int, enum REG_ICTL_MASK);
void fjes_hw_set_irqmask(struct fjes_hw *, enum REG_ICTL_MASK, bool);
u32 fjes_hw_capture_interrupt_status(struct fjes_hw *);
void fjes_hw_raise_epstop(struct fjes_hw *);
int fjes_hw_wait_epstop(struct fjes_hw *);
enum ep_partner_status
fjes_hw_get_partner_ep_status(struct fjes_hw *, int);
bool fjes_hw_epid_is_same_zone(struct fjes_hw *, int);
int fjes_hw_epid_is_shared(struct fjes_device_shared_info *, int);
bool fjes_hw_check_epbuf_version(struct epbuf_handler *, u32);
bool fjes_hw_check_mtu(struct epbuf_handler *, u32);
bool fjes_hw_check_vlan_id(struct epbuf_handler *, u16);
bool fjes_hw_set_vlan_id(struct epbuf_handler *, u16);
void fjes_hw_del_vlan_id(struct epbuf_handler *, u16);
bool fjes_hw_epbuf_rx_is_empty(struct epbuf_handler *);
void *fjes_hw_epbuf_rx_curpkt_get_addr(struct epbuf_handler *, size_t *);
void fjes_hw_epbuf_rx_curpkt_drop(struct epbuf_handler *);
int fjes_hw_epbuf_tx_pkt_send(struct epbuf_handler *, void *, size_t);
#endif /* FJES_HW_H_ */
This diff is collapsed.
/*
* FUJITSU Extended Socket Network Device driver
* Copyright (c) 2015 FUJITSU LIMITED
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see <http://www.gnu.org/licenses/>.
*
* The full GNU General Public License is included in this distribution in
* the file called "COPYING".
*
*/
#ifndef FJES_REGS_H_
#define FJES_REGS_H_
#include <linux/bitops.h>
#define XSCT_DEVICE_REGISTER_SIZE 0x1000
/* register offset */
/* Information registers */
#define XSCT_OWNER_EPID 0x0000 /* Owner EPID */
#define XSCT_MAX_EP 0x0004 /* Maximum EP */
/* Device Control registers */
#define XSCT_DCTL 0x0010 /* Device Control */
/* Command Control registers */
#define XSCT_CR 0x0020 /* Command request */
#define XSCT_CS 0x0024 /* Command status */
#define XSCT_SHSTSAL 0x0028 /* Share status address Low */
#define XSCT_SHSTSAH 0x002C /* Share status address High */
#define XSCT_REQBL 0x0034 /* Request Buffer length */
#define XSCT_REQBAL 0x0038 /* Request Buffer Address Low */
#define XSCT_REQBAH 0x003C /* Request Buffer Address High */
#define XSCT_RESPBL 0x0044 /* Response Buffer Length */
#define XSCT_RESPBAL 0x0048 /* Response Buffer Address Low */
#define XSCT_RESPBAH 0x004C /* Response Buffer Address High */
/* Interrupt Control registers */
#define XSCT_IS 0x0080 /* Interrupt status */
#define XSCT_IMS 0x0084 /* Interrupt mask set */
#define XSCT_IMC 0x0088 /* Interrupt mask clear */
#define XSCT_IG 0x008C /* Interrupt generator */
#define XSCT_ICTL 0x0090 /* Interrupt control */
/* register structure */
/* Information registers */
union REG_OWNER_EPID {
struct {
__le32 epid:16;
__le32:16;
} bits;
__le32 reg;
};
union REG_MAX_EP {
struct {
__le32 maxep:16;
__le32:16;
} bits;
__le32 reg;
};
/* Device Control registers */
union REG_DCTL {
struct {
__le32 reset:1;
__le32 rsv0:15;
__le32 rsv1:16;
} bits;
__le32 reg;
};
/* Command Control registers */
union REG_CR {
struct {
__le32 req_code:16;
__le32 err_info:14;
__le32 error:1;
__le32 req_start:1;
} bits;
__le32 reg;
};
union REG_CS {
struct {
__le32 req_code:16;
__le32 rsv0:14;
__le32 busy:1;
__le32 complete:1;
} bits;
__le32 reg;
};
/* Interrupt Control registers */
union REG_ICTL {
struct {
__le32 automak:1;
__le32 rsv0:31;
} bits;
__le32 reg;
};
enum REG_ICTL_MASK {
REG_ICTL_MASK_INFO_UPDATE = 1 << 20,
REG_ICTL_MASK_DEV_STOP_REQ = 1 << 19,
REG_ICTL_MASK_TXRX_STOP_REQ = 1 << 18,
REG_ICTL_MASK_TXRX_STOP_DONE = 1 << 17,
REG_ICTL_MASK_RX_DATA = 1 << 16,
REG_ICTL_MASK_ALL = GENMASK(20, 16),
};
enum REG_IS_MASK {
REG_IS_MASK_IS_ASSERT = 1 << 31,
REG_IS_MASK_EPID = GENMASK(15, 0),
};
struct fjes_hw;
u32 fjes_hw_rd32(struct fjes_hw *hw, u32 reg);
#define wr32(reg, val) \
do { \
u8 *base = hw->base; \
writel((val), &base[(reg)]); \
} while (0)
#define rd32(reg) (fjes_hw_rd32(hw, reg))
#endif /* FJES_REGS_H_ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment