Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    3)  *  FUJITSU Extended Socket Network Device driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    4)  *  Copyright (c) 2015 FUJITSU LIMITED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    5)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    7) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    8) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    9) #include <linux/nls.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   10) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   11) #include <linux/netdevice.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   12) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   14) #include "fjes.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   15) #include "fjes_trace.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   17) #define MAJ 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   18) #define MIN 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   19) #define DRV_VERSION __stringify(MAJ) "." __stringify(MIN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   20) #define DRV_NAME	"fjes"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   21) char fjes_driver_name[] = DRV_NAME;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   22) char fjes_driver_version[] = DRV_VERSION;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   23) static const char fjes_driver_string[] =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   24) 		"FUJITSU Extended Socket Network Device Driver";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   25) static const char fjes_copyright[] =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   26) 		"Copyright (c) 2015 FUJITSU LIMITED";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   28) MODULE_AUTHOR("Taku Izumi <izumi.taku@jp.fujitsu.com>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   29) MODULE_DESCRIPTION("FUJITSU Extended Socket Network Device Driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   30) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   31) MODULE_VERSION(DRV_VERSION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   33) #define ACPI_MOTHERBOARD_RESOURCE_HID "PNP0C02"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   35) static int fjes_request_irq(struct fjes_adapter *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   36) static void fjes_free_irq(struct fjes_adapter *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   38) static int fjes_open(struct net_device *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   39) static int fjes_close(struct net_device *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   40) static int fjes_setup_resources(struct fjes_adapter *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   41) static void fjes_free_resources(struct fjes_adapter *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   42) static netdev_tx_t fjes_xmit_frame(struct sk_buff *, struct net_device *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   43) static void fjes_raise_intr_rxdata_task(struct work_struct *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   44) static void fjes_tx_stall_task(struct work_struct *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   45) static void fjes_force_close_task(struct work_struct *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   46) static irqreturn_t fjes_intr(int, void*);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   47) static void fjes_get_stats64(struct net_device *, struct rtnl_link_stats64 *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   48) static int fjes_change_mtu(struct net_device *, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   49) static int fjes_vlan_rx_add_vid(struct net_device *, __be16 proto, u16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   50) static int fjes_vlan_rx_kill_vid(struct net_device *, __be16 proto, u16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   51) static void fjes_tx_retry(struct net_device *, unsigned int txqueue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   53) static int fjes_acpi_add(struct acpi_device *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   54) static int fjes_acpi_remove(struct acpi_device *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   55) static acpi_status fjes_get_acpi_resource(struct acpi_resource *, void*);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   57) static int fjes_probe(struct platform_device *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   58) static int fjes_remove(struct platform_device *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   59) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   60) static int fjes_sw_init(struct fjes_adapter *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   61) static void fjes_netdev_setup(struct net_device *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   62) static void fjes_irq_watch_task(struct work_struct *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   63) static void fjes_watch_unshare_task(struct work_struct *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   64) static void fjes_rx_irq(struct fjes_adapter *, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   65) static int fjes_poll(struct napi_struct *, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   67) static const struct acpi_device_id fjes_acpi_ids[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   68) 	{ACPI_MOTHERBOARD_RESOURCE_HID, 0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   69) 	{"", 0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   70) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   71) MODULE_DEVICE_TABLE(acpi, fjes_acpi_ids);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   73) static struct acpi_driver fjes_acpi_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   74) 	.name = DRV_NAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   75) 	.class = DRV_NAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   76) 	.owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   77) 	.ids = fjes_acpi_ids,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   78) 	.ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   79) 		.add = fjes_acpi_add,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   80) 		.remove = fjes_acpi_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   81) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   82) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   84) static struct platform_driver fjes_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   85) 	.driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   86) 		.name = DRV_NAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   87) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   88) 	.probe = fjes_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   89) 	.remove = fjes_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   90) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   92) static struct resource fjes_resource[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   93) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   94) 		.flags = IORESOURCE_MEM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   95) 		.start = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   96) 		.end = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   97) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   98) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   99) 		.flags = IORESOURCE_IRQ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  100) 		.start = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  101) 		.end = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  102) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  103) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  105) static bool is_extended_socket_device(struct acpi_device *device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  106) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  107) 	struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  108) 	char str_buf[sizeof(FJES_ACPI_SYMBOL) + 1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  109) 	union acpi_object *str;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  110) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  111) 	int result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  112) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  113) 	status = acpi_evaluate_object(device->handle, "_STR", NULL, &buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  114) 	if (ACPI_FAILURE(status))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  115) 		return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  116) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  117) 	str = buffer.pointer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  118) 	result = utf16s_to_utf8s((wchar_t *)str->string.pointer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  119) 				 str->string.length, UTF16_LITTLE_ENDIAN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  120) 				 str_buf, sizeof(str_buf) - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  121) 	str_buf[result] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  123) 	if (strncmp(FJES_ACPI_SYMBOL, str_buf, strlen(FJES_ACPI_SYMBOL)) != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  124) 		kfree(buffer.pointer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  125) 		return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  126) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  127) 	kfree(buffer.pointer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  128) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  129) 	return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  130) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  132) static int acpi_check_extended_socket_status(struct acpi_device *device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  133) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  134) 	unsigned long long sta;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  135) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  137) 	status = acpi_evaluate_integer(device->handle, "_STA", NULL, &sta);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  138) 	if (ACPI_FAILURE(status))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  139) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  140) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  141) 	if (!((sta & ACPI_STA_DEVICE_PRESENT) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  142) 	      (sta & ACPI_STA_DEVICE_ENABLED) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  143) 	      (sta & ACPI_STA_DEVICE_UI) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  144) 	      (sta & ACPI_STA_DEVICE_FUNCTIONING)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  145) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  146) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  147) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  148) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  149) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  150) static int fjes_acpi_add(struct acpi_device *device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  151) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  152) 	struct platform_device *plat_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  153) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  154) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  155) 	if (!is_extended_socket_device(device))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  156) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  157) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  158) 	if (acpi_check_extended_socket_status(device))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  159) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  160) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  161) 	status = acpi_walk_resources(device->handle, METHOD_NAME__CRS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  162) 				     fjes_get_acpi_resource, fjes_resource);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  163) 	if (ACPI_FAILURE(status))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  164) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  165) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  166) 	/* create platform_device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  167) 	plat_dev = platform_device_register_simple(DRV_NAME, 0, fjes_resource,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  168) 						   ARRAY_SIZE(fjes_resource));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  169) 	if (IS_ERR(plat_dev))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  170) 		return PTR_ERR(plat_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  171) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  172) 	device->driver_data = plat_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  173) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  174) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  175) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  177) static int fjes_acpi_remove(struct acpi_device *device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  178) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  179) 	struct platform_device *plat_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  180) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  181) 	plat_dev = (struct platform_device *)acpi_driver_data(device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  182) 	platform_device_unregister(plat_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  183) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  184) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  185) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  186) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  187) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  188) fjes_get_acpi_resource(struct acpi_resource *acpi_res, void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  189) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  190) 	struct acpi_resource_address32 *addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  191) 	struct acpi_resource_irq *irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  192) 	struct resource *res = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  193) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  194) 	switch (acpi_res->type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  195) 	case ACPI_RESOURCE_TYPE_ADDRESS32:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  196) 		addr = &acpi_res->data.address32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  197) 		res[0].start = addr->address.minimum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  198) 		res[0].end = addr->address.minimum +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  199) 			addr->address.address_length - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  200) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  201) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  202) 	case ACPI_RESOURCE_TYPE_IRQ:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  203) 		irq = &acpi_res->data.irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  204) 		if (irq->interrupt_count != 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  205) 			return AE_ERROR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  206) 		res[1].start = irq->interrupts[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  207) 		res[1].end = irq->interrupts[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  208) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  209) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  210) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  211) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  212) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  213) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  214) 	return AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  215) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  216) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  217) static int fjes_request_irq(struct fjes_adapter *adapter)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  218) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  219) 	struct net_device *netdev = adapter->netdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  220) 	int result = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  221) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  222) 	adapter->interrupt_watch_enable = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  223) 	if (!delayed_work_pending(&adapter->interrupt_watch_task)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  224) 		queue_delayed_work(adapter->control_wq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  225) 				   &adapter->interrupt_watch_task,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  226) 				   FJES_IRQ_WATCH_DELAY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  227) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  228) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  229) 	if (!adapter->irq_registered) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  230) 		result = request_irq(adapter->hw.hw_res.irq, fjes_intr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  231) 				     IRQF_SHARED, netdev->name, adapter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  232) 		if (result)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  233) 			adapter->irq_registered = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  234) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  235) 			adapter->irq_registered = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  236) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  237) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  238) 	return result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  239) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  240) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  241) static void fjes_free_irq(struct fjes_adapter *adapter)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  242) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  243) 	struct fjes_hw *hw = &adapter->hw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  244) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  245) 	adapter->interrupt_watch_enable = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  246) 	cancel_delayed_work_sync(&adapter->interrupt_watch_task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  247) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  248) 	fjes_hw_set_irqmask(hw, REG_ICTL_MASK_ALL, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  249) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  250) 	if (adapter->irq_registered) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  251) 		free_irq(adapter->hw.hw_res.irq, adapter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  252) 		adapter->irq_registered = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  253) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  254) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  255) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  256) static const struct net_device_ops fjes_netdev_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  257) 	.ndo_open		= fjes_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  258) 	.ndo_stop		= fjes_close,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  259) 	.ndo_start_xmit		= fjes_xmit_frame,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  260) 	.ndo_get_stats64	= fjes_get_stats64,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  261) 	.ndo_change_mtu		= fjes_change_mtu,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  262) 	.ndo_tx_timeout		= fjes_tx_retry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  263) 	.ndo_vlan_rx_add_vid	= fjes_vlan_rx_add_vid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  264) 	.ndo_vlan_rx_kill_vid = fjes_vlan_rx_kill_vid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  265) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  266) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  267) /* fjes_open - Called when a network interface is made active */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  268) static int fjes_open(struct net_device *netdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  269) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  270) 	struct fjes_adapter *adapter = netdev_priv(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  271) 	struct fjes_hw *hw = &adapter->hw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  272) 	int result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  273) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  274) 	if (adapter->open_guard)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  275) 		return -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  276) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  277) 	result = fjes_setup_resources(adapter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  278) 	if (result)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  279) 		goto err_setup_res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  280) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  281) 	hw->txrx_stop_req_bit = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  282) 	hw->epstop_req_bit = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  283) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  284) 	napi_enable(&adapter->napi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  285) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  286) 	fjes_hw_capture_interrupt_status(hw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  287) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  288) 	result = fjes_request_irq(adapter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  289) 	if (result)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  290) 		goto err_req_irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  291) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  292) 	fjes_hw_set_irqmask(hw, REG_ICTL_MASK_ALL, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  293) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  294) 	netif_tx_start_all_queues(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  295) 	netif_carrier_on(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  296) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  297) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  298) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  299) err_req_irq:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  300) 	fjes_free_irq(adapter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  301) 	napi_disable(&adapter->napi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  302) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  303) err_setup_res:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  304) 	fjes_free_resources(adapter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  305) 	return result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  306) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  307) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  308) /* fjes_close - Disables a network interface */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  309) static int fjes_close(struct net_device *netdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  310) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  311) 	struct fjes_adapter *adapter = netdev_priv(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  312) 	struct fjes_hw *hw = &adapter->hw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  313) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  314) 	int epidx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  315) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  316) 	netif_tx_stop_all_queues(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  317) 	netif_carrier_off(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  318) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  319) 	fjes_hw_raise_epstop(hw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  320) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  321) 	napi_disable(&adapter->napi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  322) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  323) 	spin_lock_irqsave(&hw->rx_status_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  324) 	for (epidx = 0; epidx < hw->max_epid; epidx++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  325) 		if (epidx == hw->my_epid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  326) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  327) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  328) 		if (fjes_hw_get_partner_ep_status(hw, epidx) ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  329) 		    EP_PARTNER_SHARED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  330) 			adapter->hw.ep_shm_info[epidx]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  331) 				   .tx.info->v1i.rx_status &=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  332) 				~FJES_RX_POLL_WORK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  333) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  334) 	spin_unlock_irqrestore(&hw->rx_status_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  335) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  336) 	fjes_free_irq(adapter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  337) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  338) 	cancel_delayed_work_sync(&adapter->interrupt_watch_task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  339) 	cancel_work_sync(&adapter->unshare_watch_task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  340) 	adapter->unshare_watch_bitmask = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  341) 	cancel_work_sync(&adapter->raise_intr_rxdata_task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  342) 	cancel_work_sync(&adapter->tx_stall_task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  343) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  344) 	cancel_work_sync(&hw->update_zone_task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  345) 	cancel_work_sync(&hw->epstop_task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  346) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  347) 	fjes_hw_wait_epstop(hw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  348) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  349) 	fjes_free_resources(adapter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  350) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  351) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  352) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  353) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  354) static int fjes_setup_resources(struct fjes_adapter *adapter)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  355) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  356) 	struct net_device *netdev = adapter->netdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  357) 	struct ep_share_mem_info *buf_pair;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  358) 	struct fjes_hw *hw = &adapter->hw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  359) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  360) 	int result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  361) 	int epidx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  362) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  363) 	mutex_lock(&hw->hw_info.lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  364) 	result = fjes_hw_request_info(hw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  365) 	switch (result) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  366) 	case 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  367) 		for (epidx = 0; epidx < hw->max_epid; epidx++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  368) 			hw->ep_shm_info[epidx].es_status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  369) 			    hw->hw_info.res_buf->info.info[epidx].es_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  370) 			hw->ep_shm_info[epidx].zone =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  371) 			    hw->hw_info.res_buf->info.info[epidx].zone;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  372) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  373) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  374) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  375) 	case -ENOMSG:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  376) 	case -EBUSY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  377) 		adapter->force_reset = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  378) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  379) 		mutex_unlock(&hw->hw_info.lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  380) 		return result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  381) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  382) 	mutex_unlock(&hw->hw_info.lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  383) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  384) 	for (epidx = 0; epidx < (hw->max_epid); epidx++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  385) 		if ((epidx != hw->my_epid) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  386) 		    (hw->ep_shm_info[epidx].es_status ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  387) 		     FJES_ZONING_STATUS_ENABLE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  388) 			fjes_hw_raise_interrupt(hw, epidx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  389) 						REG_ICTL_MASK_INFO_UPDATE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  390) 			hw->ep_shm_info[epidx].ep_stats
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  391) 				.send_intr_zoneupdate += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  392) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  393) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  394) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  395) 	msleep(FJES_OPEN_ZONE_UPDATE_WAIT * hw->max_epid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  396) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  397) 	for (epidx = 0; epidx < (hw->max_epid); epidx++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  398) 		if (epidx == hw->my_epid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  399) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  400) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  401) 		buf_pair = &hw->ep_shm_info[epidx];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  402) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  403) 		spin_lock_irqsave(&hw->rx_status_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  404) 		fjes_hw_setup_epbuf(&buf_pair->tx, netdev->dev_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  405) 				    netdev->mtu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  406) 		spin_unlock_irqrestore(&hw->rx_status_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  407) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  408) 		if (fjes_hw_epid_is_same_zone(hw, epidx)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  409) 			mutex_lock(&hw->hw_info.lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  410) 			result =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  411) 			fjes_hw_register_buff_addr(hw, epidx, buf_pair);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  412) 			mutex_unlock(&hw->hw_info.lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  413) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  414) 			switch (result) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  415) 			case 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  416) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  417) 			case -ENOMSG:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  418) 			case -EBUSY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  419) 			default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  420) 				adapter->force_reset = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  421) 				return result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  422) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  423) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  424) 			hw->ep_shm_info[epidx].ep_stats
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  425) 				.com_regist_buf_exec += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  426) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  427) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  428) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  429) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  430) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  431) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  432) static void fjes_free_resources(struct fjes_adapter *adapter)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  433) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  434) 	struct net_device *netdev = adapter->netdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  435) 	struct fjes_device_command_param param;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  436) 	struct ep_share_mem_info *buf_pair;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  437) 	struct fjes_hw *hw = &adapter->hw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  438) 	bool reset_flag = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  439) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  440) 	int result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  441) 	int epidx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  442) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  443) 	for (epidx = 0; epidx < hw->max_epid; epidx++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  444) 		if (epidx == hw->my_epid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  445) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  446) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  447) 		mutex_lock(&hw->hw_info.lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  448) 		result = fjes_hw_unregister_buff_addr(hw, epidx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  449) 		mutex_unlock(&hw->hw_info.lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  450) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  451) 		hw->ep_shm_info[epidx].ep_stats.com_unregist_buf_exec += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  452) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  453) 		if (result)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  454) 			reset_flag = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  455) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  456) 		buf_pair = &hw->ep_shm_info[epidx];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  457) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  458) 		spin_lock_irqsave(&hw->rx_status_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  459) 		fjes_hw_setup_epbuf(&buf_pair->tx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  460) 				    netdev->dev_addr, netdev->mtu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  461) 		spin_unlock_irqrestore(&hw->rx_status_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  462) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  463) 		clear_bit(epidx, &hw->txrx_stop_req_bit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  464) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  465) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  466) 	if (reset_flag || adapter->force_reset) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  467) 		result = fjes_hw_reset(hw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  468) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  469) 		adapter->force_reset = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  470) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  471) 		if (result)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  472) 			adapter->open_guard = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  473) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  474) 		hw->hw_info.buffer_share_bit = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  475) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  476) 		memset((void *)&param, 0, sizeof(param));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  477) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  478) 		param.req_len = hw->hw_info.req_buf_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  479) 		param.req_start = __pa(hw->hw_info.req_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  480) 		param.res_len = hw->hw_info.res_buf_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  481) 		param.res_start = __pa(hw->hw_info.res_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  482) 		param.share_start = __pa(hw->hw_info.share->ep_status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  483) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  484) 		fjes_hw_init_command_registers(hw, &param);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  485) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  486) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  487) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  488) static void fjes_tx_stall_task(struct work_struct *work)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  489) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  490) 	struct fjes_adapter *adapter = container_of(work,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  491) 			struct fjes_adapter, tx_stall_task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  492) 	struct net_device *netdev = adapter->netdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  493) 	struct fjes_hw *hw = &adapter->hw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  494) 	int all_queue_available, sendable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  495) 	enum ep_partner_status pstatus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  496) 	int max_epid, my_epid, epid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  497) 	union ep_buffer_info *info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  498) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  499) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  500) 	if (((long)jiffies -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  501) 		dev_trans_start(netdev)) > FJES_TX_TX_STALL_TIMEOUT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  502) 		netif_wake_queue(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  503) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  504) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  505) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  506) 	my_epid = hw->my_epid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  507) 	max_epid = hw->max_epid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  508) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  509) 	for (i = 0; i < 5; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  510) 		all_queue_available = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  511) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  512) 		for (epid = 0; epid < max_epid; epid++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  513) 			if (my_epid == epid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  514) 				continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  515) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  516) 			pstatus = fjes_hw_get_partner_ep_status(hw, epid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  517) 			sendable = (pstatus == EP_PARTNER_SHARED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  518) 			if (!sendable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  519) 				continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  520) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  521) 			info = adapter->hw.ep_shm_info[epid].tx.info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  522) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  523) 			if (!(info->v1i.rx_status & FJES_RX_MTU_CHANGING_DONE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  524) 				return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  525) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  526) 			if (EP_RING_FULL(info->v1i.head, info->v1i.tail,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  527) 					 info->v1i.count_max)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  528) 				all_queue_available = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  529) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  530) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  531) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  532) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  533) 		if (all_queue_available) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  534) 			netif_wake_queue(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  535) 			return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  536) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  537) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  538) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  539) 	usleep_range(50, 100);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  540) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  541) 	queue_work(adapter->txrx_wq, &adapter->tx_stall_task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  542) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  543) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  544) static void fjes_force_close_task(struct work_struct *work)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  545) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  546) 	struct fjes_adapter *adapter = container_of(work,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  547) 			struct fjes_adapter, force_close_task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  548) 	struct net_device *netdev = adapter->netdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  549) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  550) 	rtnl_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  551) 	dev_close(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  552) 	rtnl_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  553) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  554) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  555) static void fjes_raise_intr_rxdata_task(struct work_struct *work)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  556) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  557) 	struct fjes_adapter *adapter = container_of(work,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  558) 			struct fjes_adapter, raise_intr_rxdata_task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  559) 	struct fjes_hw *hw = &adapter->hw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  560) 	enum ep_partner_status pstatus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  561) 	int max_epid, my_epid, epid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  562) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  563) 	my_epid = hw->my_epid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  564) 	max_epid = hw->max_epid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  565) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  566) 	for (epid = 0; epid < max_epid; epid++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  567) 		hw->ep_shm_info[epid].tx_status_work = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  568) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  569) 	for (epid = 0; epid < max_epid; epid++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  570) 		if (epid == my_epid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  571) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  572) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  573) 		pstatus = fjes_hw_get_partner_ep_status(hw, epid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  574) 		if (pstatus == EP_PARTNER_SHARED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  575) 			hw->ep_shm_info[epid].tx_status_work =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  576) 				hw->ep_shm_info[epid].tx.info->v1i.tx_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  577) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  578) 			if (hw->ep_shm_info[epid].tx_status_work ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  579) 				FJES_TX_DELAY_SEND_PENDING) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  580) 				hw->ep_shm_info[epid].tx.info->v1i.tx_status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  581) 					FJES_TX_DELAY_SEND_NONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  582) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  583) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  584) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  585) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  586) 	for (epid = 0; epid < max_epid; epid++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  587) 		if (epid == my_epid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  588) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  589) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  590) 		pstatus = fjes_hw_get_partner_ep_status(hw, epid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  591) 		if ((hw->ep_shm_info[epid].tx_status_work ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  592) 		     FJES_TX_DELAY_SEND_PENDING) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  593) 		    (pstatus == EP_PARTNER_SHARED) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  594) 		    !(hw->ep_shm_info[epid].rx.info->v1i.rx_status &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  595) 		      FJES_RX_POLL_WORK)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  596) 			fjes_hw_raise_interrupt(hw, epid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  597) 						REG_ICTL_MASK_RX_DATA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  598) 			hw->ep_shm_info[epid].ep_stats.send_intr_rx += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  599) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  600) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  601) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  602) 	usleep_range(500, 1000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  603) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  604) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  605) static int fjes_tx_send(struct fjes_adapter *adapter, int dest,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  606) 			void *data, size_t len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  607) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  608) 	int retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  609) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  610) 	retval = fjes_hw_epbuf_tx_pkt_send(&adapter->hw.ep_shm_info[dest].tx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  611) 					   data, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  612) 	if (retval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  613) 		return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  614) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  615) 	adapter->hw.ep_shm_info[dest].tx.info->v1i.tx_status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  616) 		FJES_TX_DELAY_SEND_PENDING;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  617) 	if (!work_pending(&adapter->raise_intr_rxdata_task))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  618) 		queue_work(adapter->txrx_wq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  619) 			   &adapter->raise_intr_rxdata_task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  620) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  621) 	retval = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  622) 	return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  623) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  624) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  625) static netdev_tx_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  626) fjes_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  627) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  628) 	struct fjes_adapter *adapter = netdev_priv(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  629) 	struct fjes_hw *hw = &adapter->hw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  630) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  631) 	int max_epid, my_epid, dest_epid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  632) 	enum ep_partner_status pstatus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  633) 	struct netdev_queue *cur_queue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  634) 	char shortpkt[VLAN_ETH_HLEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  635) 	bool is_multi, vlan;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  636) 	struct ethhdr *eth;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  637) 	u16 queue_no = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  638) 	u16 vlan_id = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  639) 	netdev_tx_t ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  640) 	char *data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  641) 	int len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  642) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  643) 	ret = NETDEV_TX_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  644) 	is_multi = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  645) 	cur_queue = netdev_get_tx_queue(netdev, queue_no);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  646) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  647) 	eth = (struct ethhdr *)skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  648) 	my_epid = hw->my_epid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  649) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  650) 	vlan = (vlan_get_tag(skb, &vlan_id) == 0) ? true : false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  651) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  652) 	data = skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  653) 	len = skb->len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  654) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  655) 	if (is_multicast_ether_addr(eth->h_dest)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  656) 		dest_epid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  657) 		max_epid = hw->max_epid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  658) 		is_multi = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  659) 	} else if (is_local_ether_addr(eth->h_dest)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  660) 		dest_epid = eth->h_dest[ETH_ALEN - 1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  661) 		max_epid = dest_epid + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  662) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  663) 		if ((eth->h_dest[0] == 0x02) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  664) 		    (0x00 == (eth->h_dest[1] | eth->h_dest[2] |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  665) 			      eth->h_dest[3] | eth->h_dest[4])) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  666) 		    (dest_epid < hw->max_epid)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  667) 			;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  668) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  669) 			dest_epid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  670) 			max_epid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  671) 			ret = NETDEV_TX_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  672) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  673) 			adapter->stats64.tx_packets += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  674) 			hw->ep_shm_info[my_epid].net_stats.tx_packets += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  675) 			adapter->stats64.tx_bytes += len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  676) 			hw->ep_shm_info[my_epid].net_stats.tx_bytes += len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  677) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  678) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  679) 		dest_epid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  680) 		max_epid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  681) 		ret = NETDEV_TX_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  682) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  683) 		adapter->stats64.tx_packets += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  684) 		hw->ep_shm_info[my_epid].net_stats.tx_packets += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  685) 		adapter->stats64.tx_bytes += len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  686) 		hw->ep_shm_info[my_epid].net_stats.tx_bytes += len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  687) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  688) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  689) 	for (; dest_epid < max_epid; dest_epid++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  690) 		if (my_epid == dest_epid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  691) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  692) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  693) 		pstatus = fjes_hw_get_partner_ep_status(hw, dest_epid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  694) 		if (pstatus != EP_PARTNER_SHARED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  695) 			if (!is_multi)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  696) 				hw->ep_shm_info[dest_epid].ep_stats
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  697) 					.tx_dropped_not_shared += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  698) 			ret = NETDEV_TX_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  699) 		} else if (!fjes_hw_check_epbuf_version(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  700) 				&adapter->hw.ep_shm_info[dest_epid].rx, 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  701) 			/* version is NOT 0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  702) 			adapter->stats64.tx_carrier_errors += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  703) 			hw->ep_shm_info[dest_epid].net_stats
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  704) 						.tx_carrier_errors += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  705) 			hw->ep_shm_info[dest_epid].ep_stats
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  706) 					.tx_dropped_ver_mismatch += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  707) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  708) 			ret = NETDEV_TX_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  709) 		} else if (!fjes_hw_check_mtu(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  710) 				&adapter->hw.ep_shm_info[dest_epid].rx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  711) 				netdev->mtu)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  712) 			adapter->stats64.tx_dropped += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  713) 			hw->ep_shm_info[dest_epid].net_stats.tx_dropped += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  714) 			adapter->stats64.tx_errors += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  715) 			hw->ep_shm_info[dest_epid].net_stats.tx_errors += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  716) 			hw->ep_shm_info[dest_epid].ep_stats
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  717) 					.tx_dropped_buf_size_mismatch += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  718) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  719) 			ret = NETDEV_TX_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  720) 		} else if (vlan &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  721) 			   !fjes_hw_check_vlan_id(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  722) 				&adapter->hw.ep_shm_info[dest_epid].rx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  723) 				vlan_id)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  724) 			hw->ep_shm_info[dest_epid].ep_stats
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  725) 				.tx_dropped_vlanid_mismatch += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  726) 			ret = NETDEV_TX_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  727) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  728) 			if (len < VLAN_ETH_HLEN) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  729) 				memset(shortpkt, 0, VLAN_ETH_HLEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  730) 				memcpy(shortpkt, skb->data, skb->len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  731) 				len = VLAN_ETH_HLEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  732) 				data = shortpkt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  733) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  734) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  735) 			if (adapter->tx_retry_count == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  736) 				adapter->tx_start_jiffies = jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  737) 				adapter->tx_retry_count = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  738) 			} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  739) 				adapter->tx_retry_count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  740) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  741) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  742) 			if (fjes_tx_send(adapter, dest_epid, data, len)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  743) 				if (is_multi) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  744) 					ret = NETDEV_TX_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  745) 				} else if (
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  746) 					   ((long)jiffies -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  747) 					    (long)adapter->tx_start_jiffies) >=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  748) 					    FJES_TX_RETRY_TIMEOUT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  749) 					adapter->stats64.tx_fifo_errors += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  750) 					hw->ep_shm_info[dest_epid].net_stats
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  751) 								.tx_fifo_errors += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  752) 					adapter->stats64.tx_errors += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  753) 					hw->ep_shm_info[dest_epid].net_stats
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  754) 								.tx_errors += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  755) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  756) 					ret = NETDEV_TX_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  757) 				} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  758) 					netif_trans_update(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  759) 					hw->ep_shm_info[dest_epid].ep_stats
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  760) 						.tx_buffer_full += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  761) 					netif_tx_stop_queue(cur_queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  762) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  763) 					if (!work_pending(&adapter->tx_stall_task))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  764) 						queue_work(adapter->txrx_wq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  765) 							   &adapter->tx_stall_task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  766) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  767) 					ret = NETDEV_TX_BUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  768) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  769) 			} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  770) 				if (!is_multi) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  771) 					adapter->stats64.tx_packets += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  772) 					hw->ep_shm_info[dest_epid].net_stats
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  773) 								.tx_packets += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  774) 					adapter->stats64.tx_bytes += len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  775) 					hw->ep_shm_info[dest_epid].net_stats
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  776) 								.tx_bytes += len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  777) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  778) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  779) 				adapter->tx_retry_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  780) 				ret = NETDEV_TX_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  781) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  782) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  783) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  784) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  785) 	if (ret == NETDEV_TX_OK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  786) 		dev_kfree_skb(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  787) 		if (is_multi) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  788) 			adapter->stats64.tx_packets += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  789) 			hw->ep_shm_info[my_epid].net_stats.tx_packets += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  790) 			adapter->stats64.tx_bytes += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  791) 			hw->ep_shm_info[my_epid].net_stats.tx_bytes += len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  792) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  793) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  794) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  795) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  796) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  797) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  798) static void fjes_tx_retry(struct net_device *netdev, unsigned int txqueue)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  799) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  800) 	struct netdev_queue *queue = netdev_get_tx_queue(netdev, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  801) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  802) 	netif_tx_wake_queue(queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  803) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  804) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  805) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  806) fjes_get_stats64(struct net_device *netdev, struct rtnl_link_stats64 *stats)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  807) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  808) 	struct fjes_adapter *adapter = netdev_priv(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  809) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  810) 	memcpy(stats, &adapter->stats64, sizeof(struct rtnl_link_stats64));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  811) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  812) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  813) static int fjes_change_mtu(struct net_device *netdev, int new_mtu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  814) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  815) 	struct fjes_adapter *adapter = netdev_priv(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  816) 	bool running = netif_running(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  817) 	struct fjes_hw *hw = &adapter->hw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  818) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  819) 	int ret = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  820) 	int idx, epidx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  821) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  822) 	for (idx = 0; fjes_support_mtu[idx] != 0; idx++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  823) 		if (new_mtu <= fjes_support_mtu[idx]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  824) 			new_mtu = fjes_support_mtu[idx];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  825) 			if (new_mtu == netdev->mtu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  826) 				return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  827) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  828) 			ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  829) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  830) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  831) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  832) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  833) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  834) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  835) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  836) 	if (running) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  837) 		spin_lock_irqsave(&hw->rx_status_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  838) 		for (epidx = 0; epidx < hw->max_epid; epidx++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  839) 			if (epidx == hw->my_epid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  840) 				continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  841) 			hw->ep_shm_info[epidx].tx.info->v1i.rx_status &=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  842) 				~FJES_RX_MTU_CHANGING_DONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  843) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  844) 		spin_unlock_irqrestore(&hw->rx_status_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  845) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  846) 		netif_tx_stop_all_queues(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  847) 		netif_carrier_off(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  848) 		cancel_work_sync(&adapter->tx_stall_task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  849) 		napi_disable(&adapter->napi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  850) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  851) 		msleep(1000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  852) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  853) 		netif_tx_stop_all_queues(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  854) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  855) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  856) 	netdev->mtu = new_mtu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  857) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  858) 	if (running) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  859) 		for (epidx = 0; epidx < hw->max_epid; epidx++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  860) 			if (epidx == hw->my_epid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  861) 				continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  862) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  863) 			spin_lock_irqsave(&hw->rx_status_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  864) 			fjes_hw_setup_epbuf(&hw->ep_shm_info[epidx].tx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  865) 					    netdev->dev_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  866) 					    netdev->mtu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  867) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  868) 			hw->ep_shm_info[epidx].tx.info->v1i.rx_status |=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  869) 				FJES_RX_MTU_CHANGING_DONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  870) 			spin_unlock_irqrestore(&hw->rx_status_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  871) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  872) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  873) 		netif_tx_wake_all_queues(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  874) 		netif_carrier_on(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  875) 		napi_enable(&adapter->napi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  876) 		napi_schedule(&adapter->napi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  877) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  878) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  879) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  880) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  881) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  882) static int fjes_vlan_rx_add_vid(struct net_device *netdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  883) 				__be16 proto, u16 vid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  884) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  885) 	struct fjes_adapter *adapter = netdev_priv(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  886) 	bool ret = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  887) 	int epid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  888) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  889) 	for (epid = 0; epid < adapter->hw.max_epid; epid++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  890) 		if (epid == adapter->hw.my_epid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  891) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  892) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  893) 		if (!fjes_hw_check_vlan_id(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  894) 			&adapter->hw.ep_shm_info[epid].tx, vid))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  895) 			ret = fjes_hw_set_vlan_id(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  896) 				&adapter->hw.ep_shm_info[epid].tx, vid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  897) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  898) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  899) 	return ret ? 0 : -ENOSPC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  900) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  901) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  902) static int fjes_vlan_rx_kill_vid(struct net_device *netdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  903) 				 __be16 proto, u16 vid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  904) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  905) 	struct fjes_adapter *adapter = netdev_priv(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  906) 	int epid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  907) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  908) 	for (epid = 0; epid < adapter->hw.max_epid; epid++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  909) 		if (epid == adapter->hw.my_epid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  910) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  911) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  912) 		fjes_hw_del_vlan_id(&adapter->hw.ep_shm_info[epid].tx, vid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  913) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  914) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  915) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  916) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  917) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  918) static void fjes_txrx_stop_req_irq(struct fjes_adapter *adapter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  919) 				   int src_epid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  920) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  921) 	struct fjes_hw *hw = &adapter->hw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  922) 	enum ep_partner_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  923) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  924) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  925) 	status = fjes_hw_get_partner_ep_status(hw, src_epid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  926) 	trace_fjes_txrx_stop_req_irq_pre(hw, src_epid, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  927) 	switch (status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  928) 	case EP_PARTNER_UNSHARE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  929) 	case EP_PARTNER_COMPLETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  930) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  931) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  932) 	case EP_PARTNER_WAITING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  933) 		if (src_epid < hw->my_epid) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  934) 			spin_lock_irqsave(&hw->rx_status_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  935) 			hw->ep_shm_info[src_epid].tx.info->v1i.rx_status |=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  936) 				FJES_RX_STOP_REQ_DONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  937) 			spin_unlock_irqrestore(&hw->rx_status_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  938) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  939) 			clear_bit(src_epid, &hw->txrx_stop_req_bit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  940) 			set_bit(src_epid, &adapter->unshare_watch_bitmask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  941) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  942) 			if (!work_pending(&adapter->unshare_watch_task))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  943) 				queue_work(adapter->control_wq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  944) 					   &adapter->unshare_watch_task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  945) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  946) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  947) 	case EP_PARTNER_SHARED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  948) 		if (hw->ep_shm_info[src_epid].rx.info->v1i.rx_status &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  949) 		    FJES_RX_STOP_REQ_REQUEST) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  950) 			set_bit(src_epid, &hw->epstop_req_bit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  951) 			if (!work_pending(&hw->epstop_task))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  952) 				queue_work(adapter->control_wq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  953) 					   &hw->epstop_task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  954) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  955) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  956) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  957) 	trace_fjes_txrx_stop_req_irq_post(hw, src_epid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  958) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  959) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  960) static void fjes_stop_req_irq(struct fjes_adapter *adapter, int src_epid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  961) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  962) 	struct fjes_hw *hw = &adapter->hw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  963) 	enum ep_partner_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  964) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  965) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  966) 	set_bit(src_epid, &hw->hw_info.buffer_unshare_reserve_bit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  967) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  968) 	status = fjes_hw_get_partner_ep_status(hw, src_epid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  969) 	trace_fjes_stop_req_irq_pre(hw, src_epid, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  970) 	switch (status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  971) 	case EP_PARTNER_WAITING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  972) 		spin_lock_irqsave(&hw->rx_status_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  973) 		hw->ep_shm_info[src_epid].tx.info->v1i.rx_status |=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  974) 				FJES_RX_STOP_REQ_DONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  975) 		spin_unlock_irqrestore(&hw->rx_status_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  976) 		clear_bit(src_epid, &hw->txrx_stop_req_bit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  977) 		fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  978) 	case EP_PARTNER_UNSHARE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  979) 	case EP_PARTNER_COMPLETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  980) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  981) 		set_bit(src_epid, &adapter->unshare_watch_bitmask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  982) 		if (!work_pending(&adapter->unshare_watch_task))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  983) 			queue_work(adapter->control_wq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  984) 				   &adapter->unshare_watch_task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  985) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  986) 	case EP_PARTNER_SHARED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  987) 		set_bit(src_epid, &hw->epstop_req_bit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  988) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  989) 		if (!work_pending(&hw->epstop_task))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  990) 			queue_work(adapter->control_wq, &hw->epstop_task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  991) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  992) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  993) 	trace_fjes_stop_req_irq_post(hw, src_epid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  994) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  995) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  996) static void fjes_update_zone_irq(struct fjes_adapter *adapter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  997) 				 int src_epid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  998) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  999) 	struct fjes_hw *hw = &adapter->hw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) 	if (!work_pending(&hw->update_zone_task))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) 		queue_work(adapter->control_wq, &hw->update_zone_task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) static irqreturn_t fjes_intr(int irq, void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) 	struct fjes_adapter *adapter = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) 	struct fjes_hw *hw = &adapter->hw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) 	irqreturn_t ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) 	u32 icr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) 	icr = fjes_hw_capture_interrupt_status(hw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) 	if (icr & REG_IS_MASK_IS_ASSERT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) 		if (icr & REG_ICTL_MASK_RX_DATA) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) 			fjes_rx_irq(adapter, icr & REG_IS_MASK_EPID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) 			hw->ep_shm_info[icr & REG_IS_MASK_EPID].ep_stats
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) 				.recv_intr_rx += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) 		if (icr & REG_ICTL_MASK_DEV_STOP_REQ) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) 			fjes_stop_req_irq(adapter, icr & REG_IS_MASK_EPID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) 			hw->ep_shm_info[icr & REG_IS_MASK_EPID].ep_stats
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) 				.recv_intr_stop += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) 		if (icr & REG_ICTL_MASK_TXRX_STOP_REQ) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) 			fjes_txrx_stop_req_irq(adapter, icr & REG_IS_MASK_EPID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) 			hw->ep_shm_info[icr & REG_IS_MASK_EPID].ep_stats
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) 				.recv_intr_unshare += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) 		if (icr & REG_ICTL_MASK_TXRX_STOP_DONE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) 			fjes_hw_set_irqmask(hw,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) 					    REG_ICTL_MASK_TXRX_STOP_DONE, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) 		if (icr & REG_ICTL_MASK_INFO_UPDATE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) 			fjes_update_zone_irq(adapter, icr & REG_IS_MASK_EPID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) 			hw->ep_shm_info[icr & REG_IS_MASK_EPID].ep_stats
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) 				.recv_intr_zoneupdate += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) 		ret = IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) 		ret = IRQ_NONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051) static int fjes_rxframe_search_exist(struct fjes_adapter *adapter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) 				     int start_epid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) 	struct fjes_hw *hw = &adapter->hw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) 	enum ep_partner_status pstatus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) 	int max_epid, cur_epid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) 	max_epid = hw->max_epid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) 	start_epid = (start_epid + 1 + max_epid) % max_epid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) 	for (i = 0; i < max_epid; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) 		cur_epid = (start_epid + i) % max_epid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) 		if (cur_epid == hw->my_epid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) 		pstatus = fjes_hw_get_partner_ep_status(hw, cur_epid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) 		if (pstatus == EP_PARTNER_SHARED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) 			if (!fjes_hw_epbuf_rx_is_empty(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070) 				&hw->ep_shm_info[cur_epid].rx))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071) 				return cur_epid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074) 	return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) static void *fjes_rxframe_get(struct fjes_adapter *adapter, size_t *psize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078) 			      int *cur_epid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080) 	void *frame;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082) 	*cur_epid = fjes_rxframe_search_exist(adapter, *cur_epid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083) 	if (*cur_epid < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084) 		return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086) 	frame =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087) 	fjes_hw_epbuf_rx_curpkt_get_addr(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088) 		&adapter->hw.ep_shm_info[*cur_epid].rx, psize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090) 	return frame;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093) static void fjes_rxframe_release(struct fjes_adapter *adapter, int cur_epid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095) 	fjes_hw_epbuf_rx_curpkt_drop(&adapter->hw.ep_shm_info[cur_epid].rx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098) static void fjes_rx_irq(struct fjes_adapter *adapter, int src_epid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) 	struct fjes_hw *hw = &adapter->hw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102) 	fjes_hw_set_irqmask(hw, REG_ICTL_MASK_RX_DATA, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104) 	adapter->unset_rx_last = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105) 	napi_schedule(&adapter->napi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108) static int fjes_poll(struct napi_struct *napi, int budget)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) 	struct fjes_adapter *adapter =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111) 			container_of(napi, struct fjes_adapter, napi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112) 	struct net_device *netdev = napi->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113) 	struct fjes_hw *hw = &adapter->hw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) 	struct sk_buff *skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115) 	int work_done = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) 	int cur_epid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117) 	int epidx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) 	size_t frame_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) 	void *frame;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121) 	spin_lock(&hw->rx_status_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122) 	for (epidx = 0; epidx < hw->max_epid; epidx++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) 		if (epidx == hw->my_epid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126) 		if (fjes_hw_get_partner_ep_status(hw, epidx) ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) 		    EP_PARTNER_SHARED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128) 			adapter->hw.ep_shm_info[epidx]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129) 				   .tx.info->v1i.rx_status |= FJES_RX_POLL_WORK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131) 	spin_unlock(&hw->rx_status_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133) 	while (work_done < budget) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134) 		prefetch(&adapter->hw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135) 		frame = fjes_rxframe_get(adapter, &frame_len, &cur_epid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137) 		if (frame) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138) 			skb = napi_alloc_skb(napi, frame_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139) 			if (!skb) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140) 				adapter->stats64.rx_dropped += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141) 				hw->ep_shm_info[cur_epid].net_stats
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142) 							 .rx_dropped += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143) 				adapter->stats64.rx_errors += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144) 				hw->ep_shm_info[cur_epid].net_stats
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145) 							 .rx_errors += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146) 			} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147) 				skb_put_data(skb, frame, frame_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148) 				skb->protocol = eth_type_trans(skb, netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149) 				skb->ip_summed = CHECKSUM_UNNECESSARY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151) 				netif_receive_skb(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153) 				work_done++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155) 				adapter->stats64.rx_packets += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156) 				hw->ep_shm_info[cur_epid].net_stats
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157) 							 .rx_packets += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158) 				adapter->stats64.rx_bytes += frame_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159) 				hw->ep_shm_info[cur_epid].net_stats
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160) 							 .rx_bytes += frame_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162) 				if (is_multicast_ether_addr(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163) 					((struct ethhdr *)frame)->h_dest)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164) 					adapter->stats64.multicast += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) 					hw->ep_shm_info[cur_epid].net_stats
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166) 								 .multicast += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170) 			fjes_rxframe_release(adapter, cur_epid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171) 			adapter->unset_rx_last = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177) 	if (work_done < budget) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178) 		napi_complete_done(napi, work_done);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180) 		if (adapter->unset_rx_last) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181) 			adapter->rx_last_jiffies = jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1182) 			adapter->unset_rx_last = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1183) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1184) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185) 		if (((long)jiffies - (long)adapter->rx_last_jiffies) < 3) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186) 			napi_reschedule(napi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188) 			spin_lock(&hw->rx_status_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189) 			for (epidx = 0; epidx < hw->max_epid; epidx++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190) 				if (epidx == hw->my_epid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191) 					continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192) 				if (fjes_hw_get_partner_ep_status(hw, epidx) ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193) 				    EP_PARTNER_SHARED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194) 					adapter->hw.ep_shm_info[epidx].tx
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195) 						   .info->v1i.rx_status &=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196) 						~FJES_RX_POLL_WORK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198) 			spin_unlock(&hw->rx_status_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200) 			fjes_hw_set_irqmask(hw, REG_ICTL_MASK_RX_DATA, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204) 	return work_done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207) /* fjes_probe - Device Initialization Routine */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208) static int fjes_probe(struct platform_device *plat_dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210) 	struct fjes_adapter *adapter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211) 	struct net_device *netdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212) 	struct resource *res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1213) 	struct fjes_hw *hw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1214) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1216) 	err = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1217) 	netdev = alloc_netdev_mq(sizeof(struct fjes_adapter), "es%d",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1218) 				 NET_NAME_UNKNOWN, fjes_netdev_setup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1219) 				 FJES_MAX_QUEUES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1220) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1221) 	if (!netdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1222) 		goto err_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1223) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1224) 	SET_NETDEV_DEV(netdev, &plat_dev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1225) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1226) 	dev_set_drvdata(&plat_dev->dev, netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1227) 	adapter = netdev_priv(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1228) 	adapter->netdev = netdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1229) 	adapter->plat_dev = plat_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1230) 	hw = &adapter->hw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1231) 	hw->back = adapter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1232) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1233) 	/* setup the private structure */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1234) 	err = fjes_sw_init(adapter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1235) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1236) 		goto err_free_netdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1237) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1238) 	INIT_WORK(&adapter->force_close_task, fjes_force_close_task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1239) 	adapter->force_reset = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1240) 	adapter->open_guard = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1241) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1242) 	adapter->txrx_wq = alloc_workqueue(DRV_NAME "/txrx", WQ_MEM_RECLAIM, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1243) 	if (unlikely(!adapter->txrx_wq)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1244) 		err = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1245) 		goto err_free_netdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1246) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1247) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1248) 	adapter->control_wq = alloc_workqueue(DRV_NAME "/control",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1249) 					      WQ_MEM_RECLAIM, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1250) 	if (unlikely(!adapter->control_wq)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1251) 		err = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1252) 		goto err_free_txrx_wq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1253) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1254) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1255) 	INIT_WORK(&adapter->tx_stall_task, fjes_tx_stall_task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1256) 	INIT_WORK(&adapter->raise_intr_rxdata_task,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1257) 		  fjes_raise_intr_rxdata_task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1258) 	INIT_WORK(&adapter->unshare_watch_task, fjes_watch_unshare_task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1259) 	adapter->unshare_watch_bitmask = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1260) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1261) 	INIT_DELAYED_WORK(&adapter->interrupt_watch_task, fjes_irq_watch_task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1262) 	adapter->interrupt_watch_enable = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1263) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1264) 	res = platform_get_resource(plat_dev, IORESOURCE_MEM, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1265) 	if (!res) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1266) 		err = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1267) 		goto err_free_control_wq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1268) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1269) 	hw->hw_res.start = res->start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1270) 	hw->hw_res.size = resource_size(res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1271) 	hw->hw_res.irq = platform_get_irq(plat_dev, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1272) 	if (hw->hw_res.irq < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1273) 		err = hw->hw_res.irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1274) 		goto err_free_control_wq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1275) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1276) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1277) 	err = fjes_hw_init(&adapter->hw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1278) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1279) 		goto err_free_control_wq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1280) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1281) 	/* setup MAC address (02:00:00:00:00:[epid])*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1282) 	netdev->dev_addr[0] = 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1283) 	netdev->dev_addr[1] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1284) 	netdev->dev_addr[2] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1285) 	netdev->dev_addr[3] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1286) 	netdev->dev_addr[4] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1287) 	netdev->dev_addr[5] = hw->my_epid; /* EPID */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1288) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1289) 	err = register_netdev(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1290) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1291) 		goto err_hw_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1292) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1293) 	netif_carrier_off(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1294) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1295) 	fjes_dbg_adapter_init(adapter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1296) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1297) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1298) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1299) err_hw_exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1300) 	fjes_hw_exit(&adapter->hw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1301) err_free_control_wq:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1302) 	destroy_workqueue(adapter->control_wq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1303) err_free_txrx_wq:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1304) 	destroy_workqueue(adapter->txrx_wq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1305) err_free_netdev:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1306) 	free_netdev(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1307) err_out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1308) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1309) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1310) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1311) /* fjes_remove - Device Removal Routine */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1312) static int fjes_remove(struct platform_device *plat_dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1313) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1314) 	struct net_device *netdev = dev_get_drvdata(&plat_dev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1315) 	struct fjes_adapter *adapter = netdev_priv(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1316) 	struct fjes_hw *hw = &adapter->hw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1317) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1318) 	fjes_dbg_adapter_exit(adapter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1319) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1320) 	cancel_delayed_work_sync(&adapter->interrupt_watch_task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1321) 	cancel_work_sync(&adapter->unshare_watch_task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1322) 	cancel_work_sync(&adapter->raise_intr_rxdata_task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1323) 	cancel_work_sync(&adapter->tx_stall_task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1324) 	if (adapter->control_wq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1325) 		destroy_workqueue(adapter->control_wq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1326) 	if (adapter->txrx_wq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1327) 		destroy_workqueue(adapter->txrx_wq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1328) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1329) 	unregister_netdev(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1330) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1331) 	fjes_hw_exit(hw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1332) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1333) 	netif_napi_del(&adapter->napi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1334) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1335) 	free_netdev(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1336) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1337) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1338) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1339) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1340) static int fjes_sw_init(struct fjes_adapter *adapter)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1341) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1342) 	struct net_device *netdev = adapter->netdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1343) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1344) 	netif_napi_add(netdev, &adapter->napi, fjes_poll, 64);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1345) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1346) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1347) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1348) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1349) /* fjes_netdev_setup - netdevice initialization routine */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1350) static void fjes_netdev_setup(struct net_device *netdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1351) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1352) 	ether_setup(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1353) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1354) 	netdev->watchdog_timeo = FJES_TX_RETRY_INTERVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1355) 	netdev->netdev_ops = &fjes_netdev_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1356) 	fjes_set_ethtool_ops(netdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1357) 	netdev->mtu = fjes_support_mtu[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1358) 	netdev->min_mtu = fjes_support_mtu[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1359) 	netdev->max_mtu = fjes_support_mtu[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1360) 	netdev->features |= NETIF_F_HW_VLAN_CTAG_FILTER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1361) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1362) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1363) static void fjes_irq_watch_task(struct work_struct *work)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1364) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1365) 	struct fjes_adapter *adapter = container_of(to_delayed_work(work),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1366) 			struct fjes_adapter, interrupt_watch_task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1367) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1368) 	local_irq_disable();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1369) 	fjes_intr(adapter->hw.hw_res.irq, adapter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1370) 	local_irq_enable();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1371) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1372) 	if (fjes_rxframe_search_exist(adapter, 0) >= 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1373) 		napi_schedule(&adapter->napi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1374) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1375) 	if (adapter->interrupt_watch_enable) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1376) 		if (!delayed_work_pending(&adapter->interrupt_watch_task))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1377) 			queue_delayed_work(adapter->control_wq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1378) 					   &adapter->interrupt_watch_task,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1379) 					   FJES_IRQ_WATCH_DELAY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1380) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1381) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1382) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1383) static void fjes_watch_unshare_task(struct work_struct *work)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1384) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1385) 	struct fjes_adapter *adapter =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1386) 	container_of(work, struct fjes_adapter, unshare_watch_task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1387) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1388) 	struct net_device *netdev = adapter->netdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1389) 	struct fjes_hw *hw = &adapter->hw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1390) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1391) 	int unshare_watch, unshare_reserve;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1392) 	int max_epid, my_epid, epidx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1393) 	int stop_req, stop_req_done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1394) 	ulong unshare_watch_bitmask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1395) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1396) 	int wait_time = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1397) 	int is_shared;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1398) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1399) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1400) 	my_epid = hw->my_epid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1401) 	max_epid = hw->max_epid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1402) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1403) 	unshare_watch_bitmask = adapter->unshare_watch_bitmask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1404) 	adapter->unshare_watch_bitmask = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1405) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1406) 	while ((unshare_watch_bitmask || hw->txrx_stop_req_bit) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1407) 	       (wait_time < 3000)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1408) 		for (epidx = 0; epidx < max_epid; epidx++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1409) 			if (epidx == my_epid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1410) 				continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1411) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1412) 			is_shared = fjes_hw_epid_is_shared(hw->hw_info.share,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1413) 							   epidx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1414) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1415) 			stop_req = test_bit(epidx, &hw->txrx_stop_req_bit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1416) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1417) 			stop_req_done = hw->ep_shm_info[epidx].rx.info->v1i.rx_status &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1418) 					FJES_RX_STOP_REQ_DONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1419) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1420) 			unshare_watch = test_bit(epidx, &unshare_watch_bitmask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1421) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1422) 			unshare_reserve = test_bit(epidx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1423) 						   &hw->hw_info.buffer_unshare_reserve_bit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1424) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1425) 			if ((!stop_req ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1426) 			     (is_shared && (!is_shared || !stop_req_done))) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1427) 			    (is_shared || !unshare_watch || !unshare_reserve))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1428) 				continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1429) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1430) 			mutex_lock(&hw->hw_info.lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1431) 			ret = fjes_hw_unregister_buff_addr(hw, epidx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1432) 			switch (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1433) 			case 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1434) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1435) 			case -ENOMSG:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1436) 			case -EBUSY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1437) 			default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1438) 				if (!work_pending(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1439) 					&adapter->force_close_task)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1440) 					adapter->force_reset = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1441) 					schedule_work(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1442) 						&adapter->force_close_task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1443) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1444) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1445) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1446) 			mutex_unlock(&hw->hw_info.lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1447) 			hw->ep_shm_info[epidx].ep_stats
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1448) 					.com_unregist_buf_exec += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1449) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1450) 			spin_lock_irqsave(&hw->rx_status_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1451) 			fjes_hw_setup_epbuf(&hw->ep_shm_info[epidx].tx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1452) 					    netdev->dev_addr, netdev->mtu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1453) 			spin_unlock_irqrestore(&hw->rx_status_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1454) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1455) 			clear_bit(epidx, &hw->txrx_stop_req_bit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1456) 			clear_bit(epidx, &unshare_watch_bitmask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1457) 			clear_bit(epidx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1458) 				  &hw->hw_info.buffer_unshare_reserve_bit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1459) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1460) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1461) 		msleep(100);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1462) 		wait_time += 100;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1463) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1464) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1465) 	if (hw->hw_info.buffer_unshare_reserve_bit) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1466) 		for (epidx = 0; epidx < max_epid; epidx++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1467) 			if (epidx == my_epid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1468) 				continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1469) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1470) 			if (test_bit(epidx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1471) 				     &hw->hw_info.buffer_unshare_reserve_bit)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1472) 				mutex_lock(&hw->hw_info.lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1473) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1474) 				ret = fjes_hw_unregister_buff_addr(hw, epidx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1475) 				switch (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1476) 				case 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1477) 					break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1478) 				case -ENOMSG:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1479) 				case -EBUSY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1480) 				default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1481) 					if (!work_pending(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1482) 						&adapter->force_close_task)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1483) 						adapter->force_reset = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1484) 						schedule_work(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1485) 							&adapter->force_close_task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1486) 					}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1487) 					break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1488) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1489) 				mutex_unlock(&hw->hw_info.lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1490) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1491) 				hw->ep_shm_info[epidx].ep_stats
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1492) 					.com_unregist_buf_exec += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1493) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1494) 				spin_lock_irqsave(&hw->rx_status_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1495) 				fjes_hw_setup_epbuf(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1496) 					&hw->ep_shm_info[epidx].tx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1497) 					netdev->dev_addr, netdev->mtu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1498) 				spin_unlock_irqrestore(&hw->rx_status_lock,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1499) 						       flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1500) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1501) 				clear_bit(epidx, &hw->txrx_stop_req_bit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1502) 				clear_bit(epidx, &unshare_watch_bitmask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1503) 				clear_bit(epidx, &hw->hw_info.buffer_unshare_reserve_bit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1504) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1505) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1506) 			if (test_bit(epidx, &unshare_watch_bitmask)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1507) 				spin_lock_irqsave(&hw->rx_status_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1508) 				hw->ep_shm_info[epidx].tx.info->v1i.rx_status &=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1509) 						~FJES_RX_STOP_REQ_DONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1510) 				spin_unlock_irqrestore(&hw->rx_status_lock,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1511) 						       flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1512) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1513) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1514) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1515) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1516) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1517) static acpi_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1518) acpi_find_extended_socket_device(acpi_handle obj_handle, u32 level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1519) 				 void *context, void **return_value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1520) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1521) 	struct acpi_device *device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1522) 	bool *found = context;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1523) 	int result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1524) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1525) 	result = acpi_bus_get_device(obj_handle, &device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1526) 	if (result)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1527) 		return AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1528) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1529) 	if (strcmp(acpi_device_hid(device), ACPI_MOTHERBOARD_RESOURCE_HID))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1530) 		return AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1531) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1532) 	if (!is_extended_socket_device(device))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1533) 		return AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1534) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1535) 	if (acpi_check_extended_socket_status(device))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1536) 		return AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1537) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1538) 	*found = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1539) 	return AE_CTRL_TERMINATE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1540) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1541) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1542) /* fjes_init_module - Driver Registration Routine */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1543) static int __init fjes_init_module(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1544) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1545) 	bool found = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1546) 	int result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1547) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1548) 	acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1549) 			    acpi_find_extended_socket_device, NULL, &found,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1550) 			    NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1551) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1552) 	if (!found)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1553) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1554) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1555) 	pr_info("%s - version %s - %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1556) 		fjes_driver_string, fjes_driver_version, fjes_copyright);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1557) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1558) 	fjes_dbg_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1559) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1560) 	result = platform_driver_register(&fjes_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1561) 	if (result < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1562) 		fjes_dbg_exit();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1563) 		return result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1564) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1565) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1566) 	result = acpi_bus_register_driver(&fjes_acpi_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1567) 	if (result < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1568) 		goto fail_acpi_driver;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1569) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1570) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1571) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1572) fail_acpi_driver:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1573) 	platform_driver_unregister(&fjes_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1574) 	fjes_dbg_exit();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1575) 	return result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1576) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1577) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1578) module_init(fjes_init_module);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1579) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1580) /* fjes_exit_module - Driver Exit Cleanup Routine */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1581) static void __exit fjes_exit_module(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1582) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1583) 	acpi_bus_unregister_driver(&fjes_acpi_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1584) 	platform_driver_unregister(&fjes_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1585) 	fjes_dbg_exit();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1586) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1587) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1588) module_exit(fjes_exit_module);