linux/drivers/tty/ipwireless/hardware.c

// SPDX-License-Identifier: GPL-2.0
/*
 * IPWireless 3G PCMCIA Network Driver
 *
 * Original code
 *   by Stephen Blackheath <[email protected]>,
 *      Ben Martel <[email protected]>
 *
 * Copyrighted as follows:
 *   Copyright (C) 2004 by Symmetric Systems Ltd (NZ)
 *
 * Various driver changes and rewrites, port to new kernels
 *   Copyright (C) 2006-2007 Jiri Kosina
 *
 * Misc code cleanups and updates
 *   Copyright (C) 2007 David Sterba
 */

#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/irq.h>
#include <linux/kernel.h>
#include <linux/list.h>
#include <linux/slab.h>

#include "hardware.h"
#include "setup_protocol.h"
#include "network.h"
#include "main.h"

static void ipw_send_setup_packet(struct ipw_hardware *hw);
static void handle_received_SETUP_packet(struct ipw_hardware *ipw,
					 unsigned int address,
					 const unsigned char *data, int len,
					 int is_last);
static void ipwireless_setup_timer(struct timer_list *t);
static void handle_received_CTRL_packet(struct ipw_hardware *hw,
		unsigned int channel_idx, const unsigned char *data, int len);

/*#define TIMING_DIAGNOSTICS*/

#ifdef TIMING_DIAGNOSTICS

static struct timing_stats {
	unsigned long last_report_time;
	unsigned long read_time;
	unsigned long write_time;
	unsigned long read_bytes;
	unsigned long write_bytes;
	unsigned long start_time;
};

static void start_timing(void)
{
	timing_stats.start_time = jiffies;
}

static void end_read_timing(unsigned length)
{
	timing_stats.read_time += (jiffies - start_time);
	timing_stats.read_bytes += length + 2;
	report_timing();
}

static void end_write_timing(unsigned length)
{
	timing_stats.write_time += (jiffies - start_time);
	timing_stats.write_bytes += length + 2;
	report_timing();
}

static void report_timing(void)
{
	unsigned long since = jiffies - timing_stats.last_report_time;

	/* If it's been more than one second... */
	if (since >= HZ) {
		int first = (timing_stats.last_report_time == 0);

		timing_stats.last_report_time = jiffies;
		if (!first)
			printk(KERN_INFO IPWIRELESS_PCCARD_NAME
			       ": %u us elapsed - read %lu bytes in %u us, wrote %lu bytes in %u us\n",
			       jiffies_to_usecs(since),
			       timing_stats.read_bytes,
			       jiffies_to_usecs(timing_stats.read_time),
			       timing_stats.write_bytes,
			       jiffies_to_usecs(timing_stats.write_time));

		timing_stats.read_time = 0;
		timing_stats.write_time = 0;
		timing_stats.read_bytes = 0;
		timing_stats.write_bytes = 0;
	}
}
#else
static void start_timing(void) {}
static void end_read_timing(unsigned length) {}
static void end_write_timing(unsigned length) {}
#endif

/* Imported IPW definitions */

#define LL_MTU_V1
#define LL_MTU_V2
#define LL_MTU_MAX

#define PRIO_DATA
#define PRIO_CTRL
#define PRIO_SETUP

/* Addresses */
#define ADDR_SETUP_PROT

/* Protocol ids */
enum {};

/* Number of bytes in NL packet header (cannot do
 * sizeof(nl_packet_header) since it's a bitfield) */
#define NL_FIRST_PACKET_HEADER_SIZE

/* Number of bytes in NL packet header (cannot do
 * sizeof(nl_packet_header) since it's a bitfield) */
#define NL_FOLLOWING_PACKET_HEADER_SIZE

struct nl_first_packet_header {};

struct nl_packet_header {};

/* Value of 'packet_rank' above */
#define NL_INTERMEDIATE_PACKET
#define NL_LAST_PACKET
#define NL_FIRST_PACKET

nl_packet __attribute__ ((packed));

#define HW_VERSION_UNKNOWN
#define HW_VERSION_1
#define HW_VERSION_2

/* IPW I/O ports */
#define IOIER
#define IOIR
#define IODCR
#define IODRR
#define IODWR
#define IOESR
#define IORXR
#define IOTXR

/* I/O ports and bit definitions for version 1 of the hardware */

/* IER bits*/
#define IER_RXENABLED
#define IER_TXENABLED

/* ISR bits */
#define IR_RXINTR
#define IR_TXINTR

/* DCR bits */
#define DCR_RXDONE
#define DCR_TXDONE
#define DCR_RXRESET
#define DCR_TXRESET

/* I/O ports and bit definitions for version 2 of the hardware */

struct MEMCCR {};

struct MEMINFREG {};

#define CARD_PRESENT_VALUE

#define MEMTX_TX
#define MEMRX_RX
#define MEMRX_RX_DONE
#define MEMRX_PCINTACKK

#define NL_NUM_OF_PRIORITIES
#define NL_NUM_OF_PROTOCOLS
#define NL_NUM_OF_ADDRESSES

struct ipw_hardware {};

/*
 * Packet info structure for tx packets.
 * Note: not all the fields defined here are required for all protocols
 */
struct ipw_tx_packet {};

/* Signals from DTE */
#define COMCTRL_RTS
#define COMCTRL_DTR

/* Signals from DCE */
#define COMCTRL_CTS
#define COMCTRL_DCD
#define COMCTRL_DSR
#define COMCTRL_RI

struct ipw_control_packet_body {} __attribute__ ((packed));

struct ipw_control_packet {};

struct ipw_rx_packet {};

static char *data_type(const unsigned char *buf, unsigned length)
{}

#define DUMP_MAX_BYTES

static void dump_data_bytes(const char *type, const unsigned char *data,
			    unsigned length)
{}

static void swap_packet_bitfield_to_le(unsigned char *data)
{}

static void swap_packet_bitfield_from_le(unsigned char *data)
{}

static void do_send_fragment(struct ipw_hardware *hw, unsigned char *data,
			    unsigned length)
{}

static void do_send_packet(struct ipw_hardware *hw, struct ipw_tx_packet *packet)
{}

static void ipw_setup_hardware(struct ipw_hardware *hw)
{}

/*
 * If 'packet' is NULL, then this function allocates a new packet, setting its
 * length to 0 and ensuring it has the specified minimum amount of free space.
 *
 * If 'packet' is not NULL, then this function enlarges it if it doesn't
 * have the specified minimum amount of free space.
 *
 */
static struct ipw_rx_packet *pool_allocate(struct ipw_hardware *hw,
					   struct ipw_rx_packet *packet,
					   int minimum_free_space)
{}

static void pool_free(struct ipw_hardware *hw, struct ipw_rx_packet *packet)
{}

static void queue_received_packet(struct ipw_hardware *hw,
				  unsigned int protocol,
				  unsigned int address,
				  const unsigned char *data, int length,
				  int is_last)
{}

/*
 * Workqueue callback
 */
static void ipw_receive_data_work(struct work_struct *work_rx)
{}

static void handle_received_CTRL_packet(struct ipw_hardware *hw,
					unsigned int channel_idx,
					const unsigned char *data, int len)
{}

static void handle_received_packet(struct ipw_hardware *hw,
				   const union nl_packet *packet,
				   unsigned short len)
{}

static void acknowledge_data_read(struct ipw_hardware *hw)
{}

/*
 * Retrieve a packet from the IPW hardware.
 */
static void do_receive_packet(struct ipw_hardware *hw)
{}

static int get_current_packet_priority(struct ipw_hardware *hw)
{}

/*
 * return 1 if something has been received from hw
 */
static int get_packets_from_hw(struct ipw_hardware *hw)
{}

/*
 * Send pending packet up to given priority, prioritize SETUP data until
 * hardware is fully setup.
 *
 * return 1 if more packets can be sent
 */
static int send_pending_packet(struct ipw_hardware *hw, int priority_limit)
{}

/*
 * Send and receive all queued packets.
 */
static void ipwireless_do_tasklet(struct tasklet_struct *t)
{}

/*
 * return true if the card is physically present.
 */
static int is_card_present(struct ipw_hardware *hw)
{}

static irqreturn_t ipwireless_handle_v1_interrupt(int irq,
						  struct ipw_hardware *hw)
{}

static void acknowledge_pcmcia_interrupt(struct ipw_hardware *hw)
{}

static irqreturn_t ipwireless_handle_v2_v3_interrupt(int irq,
						     struct ipw_hardware *hw)
{}

irqreturn_t ipwireless_interrupt(int irq, void *dev_id)
{}

static void flush_packets_to_hw(struct ipw_hardware *hw)
{}

static void send_packet(struct ipw_hardware *hw, int priority,
			struct ipw_tx_packet *packet)
{}

/* Create data packet, non-atomic allocation */
static void *alloc_data_packet(int data_size,
				unsigned char dest_addr,
				unsigned char protocol)
{}

static void *alloc_ctrl_packet(int header_size,
			       unsigned char dest_addr,
			       unsigned char protocol,
			       unsigned char sig_no)
{}

int ipwireless_send_packet(struct ipw_hardware *hw, unsigned int channel_idx,
			    const u8 *data, unsigned int length,
			    void (*callback) (void *cb, unsigned int length),
			    void *callback_data)
{}

static int set_control_line(struct ipw_hardware *hw, int prio,
			   unsigned int channel_idx, int line, int state)
{}


static int set_DTR(struct ipw_hardware *hw, int priority,
		   unsigned int channel_idx, int state)
{}

static int set_RTS(struct ipw_hardware *hw, int priority,
		   unsigned int channel_idx, int state)
{}

int ipwireless_set_DTR(struct ipw_hardware *hw, unsigned int channel_idx,
		       int state)
{}

int ipwireless_set_RTS(struct ipw_hardware *hw, unsigned int channel_idx,
		       int state)
{}

struct ipw_setup_get_version_query_packet {};

struct ipw_setup_config_packet {};

struct ipw_setup_config_done_packet {};

struct ipw_setup_open_packet {};

struct ipw_setup_info_packet {};

struct ipw_setup_reboot_msg_ack {};

/* This handles the actual initialization of the card */
static void __handle_setup_get_version_rsp(struct ipw_hardware *hw)
{}

static void handle_setup_get_version_rsp(struct ipw_hardware *hw,
		unsigned char vers_no)
{}

static void ipw_send_setup_packet(struct ipw_hardware *hw)
{}

static void handle_received_SETUP_packet(struct ipw_hardware *hw,
					 unsigned int address,
					 const unsigned char *data, int len,
					 int is_last)
{}

static void do_close_hardware(struct ipw_hardware *hw)
{}

struct ipw_hardware *ipwireless_hardware_create(void)
{}

void ipwireless_init_hardware_v1(struct ipw_hardware *hw,
		unsigned int base_port,
		void __iomem *attr_memory,
		void __iomem *common_memory,
		int is_v2_card,
		void (*reboot_callback) (void *data),
		void *reboot_callback_data)
{}

void ipwireless_init_hardware_v2_v3(struct ipw_hardware *hw)
{}

static void ipwireless_setup_timer(struct timer_list *t)
{}

/*
 * Stop any interrupts from executing so that, once this function returns,
 * other layers of the driver can be sure they won't get any more callbacks.
 * Thus must be called on a proper process context.
 */
void ipwireless_stop_interrupts(struct ipw_hardware *hw)
{}

void ipwireless_hardware_free(struct ipw_hardware *hw)
{}

/*
 * Associate the specified network with this hardware, so it will receive events
 * from it.
 */
void ipwireless_associate_network(struct ipw_hardware *hw,
				  struct ipw_network *network)
{}