14 |
#include "net.h" |
#include "net.h" |
15 |
#include "device.h" |
#include "device.h" |
16 |
#include "pci_dev.h" |
#include "pci_dev.h" |
17 |
#include "nmc93c46.h" |
#include "nmc93cX6.h" |
18 |
#include "net_io.h" |
#include "net_io.h" |
19 |
#include "vm.h" |
#include "vm.h" |
20 |
|
|
48 |
/* C3600 NM Management Interrupt handler */ |
/* C3600 NM Management Interrupt handler */ |
49 |
#define C3600_NM_MGMT_IRQ 3 |
#define C3600_NM_MGMT_IRQ 3 |
50 |
|
|
51 |
|
/* Network IRQ */ |
52 |
|
#define C3600_NETIO_IRQ_BASE 32 |
53 |
|
#define C3600_NETIO_IRQ_PORT_BITS 2 |
54 |
|
#define C3600_NETIO_IRQ_PORT_MASK ((1 << C3600_NETIO_IRQ_PORT_BITS) - 1) |
55 |
|
#define C3600_NETIO_IRQ_PER_SLOT (1 << C3600_NETIO_IRQ_PORT_BITS) |
56 |
|
#define C3600_NETIO_IRQ_END \ |
57 |
|
(C3600_NETIO_IRQ_BASE + (C3600_MAX_NM_BAYS * C3600_NETIO_IRQ_PER_SLOT) - 1) |
58 |
|
|
59 |
/* C3600 common device addresses */ |
/* C3600 common device addresses */ |
60 |
#define C3600_GT64K_ADDR 0x14000000ULL |
#define C3600_GT64K_ADDR 0x14000000ULL |
61 |
#define C3600_IOFPGA_ADDR 0x1e800000ULL |
#define C3600_IOFPGA_ADDR 0x1e800000ULL |
72 |
/* C3600 ELF Platform ID */ |
/* C3600 ELF Platform ID */ |
73 |
#define C3620_ELF_MACHINE_ID 0x1e |
#define C3620_ELF_MACHINE_ID 0x1e |
74 |
#define C3640_ELF_MACHINE_ID 0x1e |
#define C3640_ELF_MACHINE_ID 0x1e |
75 |
//#define C3660_ELF_MACHINE_ID ???? |
#define C3660_ELF_MACHINE_ID 0x34 |
76 |
|
|
77 |
|
#define VM_C3600(vm) ((c3600_t *)vm->hw_data) |
78 |
|
|
79 |
/* C3600 router */ |
/* C3600 router */ |
80 |
typedef struct c3600_router c3600_t; |
typedef struct c3600_router c3600_t; |
81 |
|
|
|
/* C3600 EEPROM */ |
|
|
struct c3600_eeprom { |
|
|
char *name; |
|
|
m_uint16_t *data; |
|
|
u_int len; |
|
|
}; |
|
|
|
|
82 |
/* Prototype of chassis driver initialization function */ |
/* Prototype of chassis driver initialization function */ |
83 |
typedef int (*c3600_chassis_init_fn)(c3600_t *router); |
typedef int (*c3600_chassis_init_fn)(c3600_t *router); |
84 |
|
|
|
/* Prototype of NM driver initialization function */ |
|
|
typedef int (*c3600_nm_init_fn)(c3600_t *router,char *name,u_int nm_bay); |
|
|
|
|
|
/* Prototype of NM driver shutdown function */ |
|
|
typedef int (*c3600_nm_shutdown_fn)(c3600_t *router,u_int nm_bay); |
|
|
|
|
|
/* Prototype of NM NIO set function */ |
|
|
typedef int (*c3600_nm_set_nio_fn)(c3600_t *router,u_int nm_bay,u_int port_id, |
|
|
netio_desc_t *nio); |
|
|
|
|
|
/* Prototype of NM NIO unset function */ |
|
|
typedef int (*c3600_nm_unset_nio_fn)(c3600_t *router,u_int nm_bay, |
|
|
u_int port_id); |
|
|
|
|
|
/* Prototype of NM NIO show info function */ |
|
|
typedef int (*c3600_nm_show_info_fn)(c3600_t *router,u_int nm_bay); |
|
|
|
|
|
/* C3600 Network Module Driver */ |
|
|
struct c3600_nm_driver { |
|
|
char *dev_type; |
|
|
int supported; |
|
|
int wic_slots; |
|
|
c3600_nm_init_fn nm_init; |
|
|
c3600_nm_shutdown_fn nm_shutdown; |
|
|
c3600_nm_set_nio_fn nm_set_nio; |
|
|
c3600_nm_unset_nio_fn nm_unset_nio; |
|
|
c3600_nm_show_info_fn nm_show_info; |
|
|
|
|
|
/* TODO: WAN Interface Cards (WIC) */ |
|
|
}; |
|
|
|
|
|
/* C3600 NIO binding to a slot/port */ |
|
|
struct c3600_nio_binding { |
|
|
netio_desc_t *nio; |
|
|
u_int port_id; |
|
|
struct c3600_nio_binding *prev,*next; |
|
|
}; |
|
|
|
|
|
/* C3600 NM bay */ |
|
|
struct c3600_nm_bay { |
|
|
char *dev_name; /* Device name */ |
|
|
char *dev_type; /* Device Type */ |
|
|
struct pci_bus *pci_map; /* PCI bus */ |
|
|
m_uint16_t *eeprom_data; /* NM EEPROM data */ |
|
|
u_int eeprom_data_len; /* NM EEPROM data length */ |
|
|
struct c3600_nm_driver *nm_driver; /* NM Driver */ |
|
|
void *drv_info; /* Private driver info */ |
|
|
struct c3600_nio_binding *nio_list; /* NIO bindings to ports */ |
|
|
}; |
|
|
|
|
85 |
/* C3600 Chassis Driver */ |
/* C3600 Chassis Driver */ |
86 |
struct c3600_chassis_driver { |
struct c3600_chassis_driver { |
87 |
char *chassis_type; |
char *chassis_type; |
88 |
int chassis_id; |
int chassis_id; |
89 |
int supported; |
int supported; |
90 |
c3600_chassis_init_fn chassis_init; |
c3600_chassis_init_fn chassis_init; |
91 |
m_uint16_t *mb_eeprom; |
struct cisco_eeprom *eeprom; |
|
u_int mb_eeprom_len; |
|
92 |
}; |
}; |
93 |
|
|
94 |
/* C3600 router */ |
/* C3600 router */ |
99 |
/* Associated VM instance */ |
/* Associated VM instance */ |
100 |
vm_instance_t *vm; |
vm_instance_t *vm; |
101 |
|
|
102 |
/* IO memory size to be passed to Smart Init */ |
/* I/O FPGA */ |
103 |
u_int nm_iomem_size; |
struct c3600_iofpga_data *iofpga_data; |
104 |
|
|
105 |
/* Chassis information */ |
/* Chassis information */ |
106 |
struct c3600_chassis_driver *chassis_driver; |
struct c3600_chassis_driver *chassis_driver; |
|
struct c3600_nm_bay nm_bay[C3600_MAX_NM_BAYS]; |
|
107 |
m_uint8_t oir_status; |
m_uint8_t oir_status; |
108 |
|
|
109 |
/* |
/* |
110 |
* Mainboard EEPROM. |
* Mainboard EEPROM. |
111 |
* It can be modified to change the chassis MAC address. |
* It can be modified to change the chassis MAC address. |
112 |
*/ |
*/ |
113 |
m_uint16_t mb_eeprom_data[64]; |
struct cisco_eeprom mb_eeprom; |
114 |
struct nmc93c46_eeprom_def mb_eeprom; |
struct nmc93cX6_group mb_eeprom_group; |
|
struct nmc93c46_group mb_eeprom_group; |
|
115 |
|
|
116 |
/* Network Module EEPROMs (3620/3640) */ |
/* Network Module EEPROMs (3620/3640) */ |
117 |
struct nmc93c46_eeprom_def nm_eeprom; |
struct nmc93cX6_group nm_eeprom_group; |
|
struct nmc93c46_group nm_eeprom_group; |
|
118 |
|
|
119 |
/* Cisco 3660 NM EEPROMs */ |
/* Cisco 3660 NM EEPROMs */ |
120 |
struct nmc93c46_eeprom_def c3660_nm_eeprom_def[C3600_MAX_NM_BAYS]; |
struct nmc93cX6_group c3660_nm_eeprom_group[C3600_MAX_NM_BAYS]; |
|
struct nmc93c46_group c3660_nm_eeprom_group[C3600_MAX_NM_BAYS]; |
|
121 |
}; |
}; |
122 |
|
|
123 |
/* Create a new router instance */ |
/* Set EEPROM for the specified slot */ |
124 |
c3600_t *c3600_create_instance(char *name,int instance_id); |
int c3600_set_slot_eeprom(c3600_t *router,u_int slot, |
125 |
|
struct cisco_eeprom *eeprom); |
|
/* Delete a router instance */ |
|
|
int c3600_delete_instance(char *name); |
|
|
|
|
|
/* Delete all router instances */ |
|
|
int c3600_delete_all_instances(void); |
|
|
|
|
|
/* Save configuration of a C3600 instance */ |
|
|
void c3600_save_config(c3600_t *router,FILE *fd); |
|
|
|
|
|
/* Save configurations of all C3600 instances */ |
|
|
void c3600_save_config_all(FILE *fd); |
|
|
|
|
|
/* Set NM EEPROM definition */ |
|
|
int c3600_nm_set_eeprom(c3600_t *router,u_int nm_bay, |
|
|
const struct c3600_eeprom *eeprom); |
|
|
|
|
|
/* Unset NM EEPROM definition (empty bay) */ |
|
|
int c3600_nm_unset_eeprom(c3600_t *router,u_int nm_bay); |
|
|
|
|
|
/* Check if a bay has a Network Module */ |
|
|
int c3600_nm_check_eeprom(c3600_t *router,u_int nm_bay); |
|
|
|
|
|
/* Get bay info */ |
|
|
struct c3600_nm_bay *c3600_nm_get_info(c3600_t *router,u_int nm_bay); |
|
|
|
|
|
/* Get NM type */ |
|
|
char *c3600_nm_get_type(c3600_t *router,u_int nm_bay); |
|
|
|
|
|
/* Get driver info about the specified slot */ |
|
|
void *c3600_nm_get_drvinfo(c3600_t *router,u_int nm_bay); |
|
126 |
|
|
127 |
/* Set driver info for the specified slot */ |
/* Get network IRQ for specified slot/port */ |
128 |
int c3600_nm_set_drvinfo(c3600_t *router,u_int nm_bay,void *drv_info); |
u_int c3600_net_irq_for_slot_port(u_int slot,u_int port); |
|
|
|
|
/* Add a NM binding */ |
|
|
int c3600_nm_add_binding(c3600_t *router,char *dev_type,u_int nm_bay); |
|
|
|
|
|
/* Remove a NM binding */ |
|
|
int c3600_nm_remove_binding(c3600_t *router,u_int nm_bay); |
|
|
|
|
|
/* Find a NIO binding */ |
|
|
struct c3600_nio_binding * |
|
|
c3600_nm_find_nio_binding(c3600_t *router,u_int nm_bay,u_int port_id); |
|
|
|
|
|
/* Add a network IO binding */ |
|
|
int c3600_nm_add_nio_binding(c3600_t *router,u_int nm_bay,u_int port_id, |
|
|
char *nio_name); |
|
|
|
|
|
/* Remove a NIO binding */ |
|
|
int c3600_nm_remove_nio_binding(c3600_t *router,u_int nm_bay,u_int port_id); |
|
|
|
|
|
/* Remove all NIO bindings for the specified NM */ |
|
|
int c3600_nm_remove_all_nio_bindings(c3600_t *router,u_int nm_bay); |
|
|
|
|
|
/* Enable a Network IO descriptor for a Network Module */ |
|
|
int c3600_nm_enable_nio(c3600_t *router,u_int nm_bay,u_int port_id); |
|
|
|
|
|
/* Disable Network IO descriptor of a Network Module */ |
|
|
int c3600_nm_disable_nio(c3600_t *router,u_int nm_bay,u_int port_id); |
|
|
|
|
|
/* Enable all NIO of the specified NM */ |
|
|
int c3600_nm_enable_all_nio(c3600_t *router,u_int nm_bay); |
|
|
|
|
|
/* Disable all NIO of the specified NM */ |
|
|
int c3600_nm_disable_all_nio(c3600_t *router,u_int nm_bay); |
|
|
|
|
|
/* Initialize a Network Module */ |
|
|
int c3600_nm_init(c3600_t *router,u_int nm_bay); |
|
|
|
|
|
/* Shutdown a Network Module */ |
|
|
int c3600_nm_shutdown(c3600_t *router,u_int nm_bay); |
|
|
|
|
|
/* Shutdown all NM of a router */ |
|
|
int c3600_nm_shutdown_all(c3600_t *router); |
|
|
|
|
|
/* Show info about all NMs */ |
|
|
int c3600_nm_show_all_info(c3600_t *router); |
|
|
|
|
|
/* Create a Network Module (command line) */ |
|
|
int c3600_cmd_nm_create(c3600_t *router,char *str); |
|
|
|
|
|
/* Add a Network IO descriptor binding (command line) */ |
|
|
int c3600_cmd_add_nio(c3600_t *router,char *str); |
|
129 |
|
|
130 |
/* Show the list of available NM drivers */ |
/* Show the list of available NM drivers */ |
131 |
void c3600_nm_show_drivers(void); |
void c3600_nm_show_drivers(void); |
139 |
/* Get the chassis ID */ |
/* Get the chassis ID */ |
140 |
int c3600_chassis_get_id(c3600_t *router); |
int c3600_chassis_get_id(c3600_t *router); |
141 |
|
|
|
/* Show the list of available chassis drivers */ |
|
|
void c3600_chassis_show_drivers(void); |
|
|
|
|
142 |
/* Show C3600 hardware info */ |
/* Show C3600 hardware info */ |
143 |
void c3600_show_hardware(c3600_t *router); |
void c3600_show_hardware(c3600_t *router); |
144 |
|
|
|
/* Initialize default parameters for a C3600 */ |
|
|
void c3600_init_defaults(c3600_t *router); |
|
|
|
|
|
/* Initialize the C3600 Platform */ |
|
|
int c3600_init_platform(c3600_t *router); |
|
|
|
|
|
/* Initialize a Cisco 3600 instance */ |
|
|
int c3600_init_instance(c3600_t *router); |
|
|
|
|
|
/* Stop a Cisco 3600 instance */ |
|
|
int c3600_stop_instance(c3600_t *router); |
|
|
|
|
145 |
/* Initialize EEPROM groups */ |
/* Initialize EEPROM groups */ |
146 |
void c3600_init_eeprom_groups(c3600_t *router); |
void c3600_init_eeprom_groups(c3600_t *router); |
147 |
|
|
148 |
/* dev_c3600_iofpga_init() */ |
/* dev_c3600_iofpga_init() */ |
149 |
int dev_c3600_iofpga_init(c3600_t *router,m_uint64_t paddr,m_uint32_t len); |
int dev_c3600_iofpga_init(c3600_t *router,m_uint64_t paddr,m_uint32_t len); |
150 |
|
|
151 |
|
/* Register the c3600 platform */ |
152 |
|
int c3600_platform_register(void); |
153 |
|
|
154 |
|
/* Hypervisor C3600 initialization */ |
155 |
|
extern int hypervisor_c3600_init(vm_platform_t *platform); |
156 |
|
|
157 |
/* NM drivers */ |
/* NM drivers */ |
158 |
extern struct c3600_nm_driver dev_c3600_nm_1e_driver; |
extern struct cisco_card_driver dev_c3600_nm_1e_driver; |
159 |
extern struct c3600_nm_driver dev_c3600_nm_4e_driver; |
extern struct cisco_card_driver dev_c3600_nm_4e_driver; |
160 |
extern struct c3600_nm_driver dev_c3600_nm_1fe_tx_driver; |
extern struct cisco_card_driver dev_c3600_nm_1fe_tx_driver; |
161 |
extern struct c3600_nm_driver dev_c3600_nm_4t_driver; |
extern struct cisco_card_driver dev_c3600_nm_4t_driver; |
162 |
extern struct c3600_nm_driver dev_c3600_leopard_2fe_driver; |
extern struct cisco_card_driver dev_c3600_leopard_2fe_driver; |
163 |
extern struct c3600_nm_driver dev_c3600_nm_16esw_driver; |
extern struct cisco_card_driver dev_c3600_nm_16esw_driver; |
164 |
|
|
165 |
#endif |
#endif |