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 "dev_mpc860.h" |
#include "dev_mpc860.h" |
20 |
#include "vm.h" |
#include "vm.h" |
31 |
#define C2600_DEFAULT_DISK1_SIZE 0 |
#define C2600_DEFAULT_DISK1_SIZE 0 |
32 |
#define C2600_DEFAULT_IOMEM_SIZE 15 /* Percents! */ |
#define C2600_DEFAULT_IOMEM_SIZE 15 /* Percents! */ |
33 |
|
|
34 |
/* 2600 characteristics: 1 NM + mainboard */ |
/* 2600 characteristics: 1 NM + mainboard, 2 onboard WIC slots */ |
35 |
#define C2600_MAX_NM_BAYS 2 |
#define C2600_MAX_NM_BAYS 2 |
36 |
|
#define C2600_MAX_WIC_BAYS 2 |
37 |
|
|
38 |
/* C2600 Virtual Timer Interrupt */ |
/* C2600 Virtual Timer Interrupt */ |
39 |
#define C2600_VTIMER_IRQ 0 |
#define C2600_VTIMER_IRQ 0 |
47 |
/* C2600 PA Management Interrupt */ |
/* C2600 PA Management Interrupt */ |
48 |
#define C2600_PA_MGMT_IRQ 3 |
#define C2600_PA_MGMT_IRQ 3 |
49 |
|
|
50 |
|
/* Network IRQ */ |
51 |
|
#define C2600_NETIO_IRQ_BASE 32 |
52 |
|
#define C2600_NETIO_IRQ_PORT_BITS 2 |
53 |
|
#define C2600_NETIO_IRQ_PORT_MASK ((1 << C2600_NETIO_IRQ_PORT_BITS) - 1) |
54 |
|
#define C2600_NETIO_IRQ_PER_SLOT (1 << C2600_NETIO_IRQ_PORT_BITS) |
55 |
|
#define C2600_NETIO_IRQ_END \ |
56 |
|
(C2600_NETIO_IRQ_BASE + (C2600_MAX_NM_BAYS * C2600_NETIO_IRQ_PER_SLOT) - 1) |
57 |
|
|
58 |
/* C2600 common device addresses */ |
/* C2600 common device addresses */ |
59 |
|
#define C2600_FLASH_ADDR 0x60000000ULL |
60 |
|
#define C2600_WIC_ADDR 0x67000000ULL |
61 |
#define C2600_IOFPGA_ADDR 0x67400000ULL |
#define C2600_IOFPGA_ADDR 0x67400000ULL |
62 |
#define C2600_NVRAM_ADDR 0x67c00000ULL |
#define C2600_NVRAM_ADDR 0x67c00000ULL |
|
#define C2600_FLASH_ADDR 0x60000000ULL |
|
63 |
#define C2600_PCICTRL_ADDR 0x68000000ULL |
#define C2600_PCICTRL_ADDR 0x68000000ULL |
64 |
#define C2600_MPC860_ADDR 0x68010000ULL |
#define C2600_MPC860_ADDR 0x68010000ULL |
65 |
#define C2600_DUART_ADDR 0xffe00000ULL |
#define C2600_DUART_ADDR 0xffe00000ULL |
66 |
#define C2600_ROM_ADDR 0xfff00000ULL |
#define C2600_ROM_ADDR 0xfff00000ULL |
67 |
|
|
68 |
|
/* WIC interval in address space */ |
69 |
|
#define C2600_WIC_SIZE 0x400 |
70 |
|
|
71 |
/* Reserved space for ROM in NVRAM */ |
/* Reserved space for ROM in NVRAM */ |
72 |
#define C2600_NVRAM_ROM_RES_SIZE 2048 |
#define C2600_NVRAM_ROM_RES_SIZE 2048 |
73 |
|
|
74 |
/* C2600 ELF Platform ID */ |
/* C2600 ELF Platform ID */ |
75 |
#define C2600_ELF_MACHINE_ID 0x2b |
#define C2600_ELF_MACHINE_ID 0x2b |
76 |
|
|
77 |
|
#define VM_C2600(vm) ((c2600_t *)vm->hw_data) |
78 |
|
|
79 |
/* C2600 router */ |
/* C2600 router */ |
80 |
typedef struct c2600_router c2600_t; |
typedef struct c2600_router c2600_t; |
81 |
|
|
|
/* Prototype of NM driver initialization function */ |
|
|
typedef int (*c2600_nm_init_fn)(c2600_t *router,char *name,u_int nm_bay); |
|
|
|
|
|
/* Prototype of NM driver shutdown function */ |
|
|
typedef int (*c2600_nm_shutdown_fn)(c2600_t *router,u_int nm_bay); |
|
|
|
|
|
/* Prototype of NM NIO set function */ |
|
|
typedef int (*c2600_nm_set_nio_fn)(c2600_t *router,u_int nm_bay,u_int port_id, |
|
|
netio_desc_t *nio); |
|
|
|
|
|
/* Prototype of NM NIO unset function */ |
|
|
typedef int (*c2600_nm_unset_nio_fn)(c2600_t *router,u_int nm_bay, |
|
|
u_int port_id); |
|
|
|
|
|
/* Prototype of NM NIO show info function */ |
|
|
typedef int (*c2600_nm_show_info_fn)(c2600_t *router,u_int nm_bay); |
|
|
|
|
|
/* C2600 Network Module Driver */ |
|
|
struct c2600_nm_driver { |
|
|
char *dev_type; |
|
|
int supported; |
|
|
int wic_slots; |
|
|
c2600_nm_init_fn nm_init; |
|
|
c2600_nm_shutdown_fn nm_shutdown; |
|
|
c2600_nm_set_nio_fn nm_set_nio; |
|
|
c2600_nm_unset_nio_fn nm_unset_nio; |
|
|
c2600_nm_show_info_fn nm_show_info; |
|
|
|
|
|
/* TODO: WAN Interface Cards (WIC) */ |
|
|
}; |
|
|
|
|
|
/* C2600 NIO binding to a slot/port */ |
|
|
struct c2600_nio_binding { |
|
|
netio_desc_t *nio; |
|
|
u_int port_id; |
|
|
struct c2600_nio_binding *prev,*next; |
|
|
}; |
|
|
|
|
|
/* C2600 NM bay */ |
|
|
struct c2600_nm_bay { |
|
|
char *dev_name; /* Device name */ |
|
|
char *dev_type; /* Device Type */ |
|
|
struct cisco_eeprom eeprom; /* NM EEPROM */ |
|
|
struct pci_bus *pci_map; /* PCI bus */ |
|
|
struct c2600_nm_driver *nm_driver; /* NM Driver */ |
|
|
void *drv_info; /* Private driver info */ |
|
|
struct c2600_nio_binding *nio_list; /* NIO bindings to ports */ |
|
|
}; |
|
|
|
|
82 |
/* C2600 router */ |
/* C2600 router */ |
83 |
struct c2600_router { |
struct c2600_router { |
84 |
/* Mainboard type (2610, 2611, etc) */ |
/* Mainboard type (2610, 2611, etc) */ |
85 |
char *mainboard_type; |
char *mainboard_type; |
86 |
|
|
87 |
|
/* Is the router a XM model ? */ |
88 |
|
int xm_model; |
89 |
|
|
90 |
/* Chassis MAC address */ |
/* Chassis MAC address */ |
91 |
n_eth_addr_t mac_addr; |
n_eth_addr_t mac_addr; |
92 |
|
|
93 |
/* Associated VM instance */ |
/* Associated VM instance */ |
94 |
vm_instance_t *vm; |
vm_instance_t *vm; |
95 |
|
|
96 |
/* IO memory size to be passed to Smart Init */ |
/* I/O FPGA */ |
97 |
u_int nm_iomem_size; |
struct c2600_iofpga_data *iofpga_data; |
|
|
|
|
/* Chassis information */ |
|
|
struct c2600_nm_bay nm_bay[C2600_MAX_NM_BAYS]; |
|
|
m_uint8_t oir_status; |
|
98 |
|
|
99 |
/* |
/* |
100 |
* Mainboard EEPROM. |
* Mainboard EEPROM. |
101 |
* It can be modified to change the chassis MAC address. |
* It can be modified to change the chassis MAC address. |
102 |
*/ |
*/ |
103 |
struct cisco_eeprom mb_eeprom; |
struct cisco_eeprom mb_eeprom; |
104 |
struct nmc93c46_group mb_eeprom_group; |
struct nmc93cX6_group mb_eeprom_group; |
105 |
|
|
106 |
/* Network Module EEPROM */ |
/* Network Module EEPROM */ |
107 |
struct nmc93c46_group nm_eeprom_group; |
struct nmc93cX6_group nm_eeprom_group; |
108 |
|
|
109 |
/* MPC860 device private data */ |
/* MPC860 device private data */ |
110 |
struct mpc860_data *mpc_data; |
struct mpc860_data *mpc_data; |
111 |
}; |
}; |
112 |
|
|
113 |
/* Create a new router instance */ |
/* Get WIC device address for the specified onboard port */ |
114 |
c2600_t *c2600_create_instance(char *name,int instance_id); |
int c2600_get_onboard_wic_addr(u_int slot,m_uint64_t *phys_addr); |
|
|
|
|
/* Delete a router instance */ |
|
|
int c2600_delete_instance(char *name); |
|
|
|
|
|
/* Delete all router instances */ |
|
|
int c2600_delete_all_instances(void); |
|
|
|
|
|
/* Save configuration of a C2600 instance */ |
|
|
void c2600_save_config(c2600_t *router,FILE *fd); |
|
|
|
|
|
/* Save configurations of all C2600 instances */ |
|
|
void c2600_save_config_all(FILE *fd); |
|
|
|
|
|
/* Show all available mainboards */ |
|
|
void c2600_mainboard_show_drivers(void); |
|
|
|
|
|
/* Set NM EEPROM definition */ |
|
|
int c2600_nm_set_eeprom(c2600_t *router,u_int nm_bay, |
|
|
const struct cisco_eeprom *eeprom); |
|
|
|
|
|
/* Unset NM EEPROM definition (empty bay) */ |
|
|
int c2600_nm_unset_eeprom(c2600_t *router,u_int nm_bay); |
|
|
|
|
|
/* Check if a bay has a Network Module */ |
|
|
int c2600_nm_check_eeprom(c2600_t *router,u_int nm_bay); |
|
|
|
|
|
/* Get bay info */ |
|
|
struct c2600_nm_bay *c2600_nm_get_info(c2600_t *router,u_int nm_bay); |
|
|
|
|
|
/* Get NM type */ |
|
|
char *c2600_nm_get_type(c2600_t *router,u_int nm_bay); |
|
115 |
|
|
116 |
/* Get driver info about the specified slot */ |
/* Set EEPROM for the specified slot */ |
117 |
void *c2600_nm_get_drvinfo(c2600_t *router,u_int nm_bay); |
int c2600_set_slot_eeprom(c2600_t *router,u_int slot, |
118 |
|
struct cisco_eeprom *eeprom); |
119 |
|
|
120 |
/* Set driver info for the specified slot */ |
/* Get network IRQ for specified slot/port */ |
121 |
int c2600_nm_set_drvinfo(c2600_t *router,u_int nm_bay,void *drv_info); |
u_int c2600_net_irq_for_slot_port(u_int slot,u_int port); |
|
|
|
|
/* Add a NM binding */ |
|
|
int c2600_nm_add_binding(c2600_t *router,char *dev_type,u_int nm_bay); |
|
|
|
|
|
/* Remove a NM binding */ |
|
|
int c2600_nm_remove_binding(c2600_t *router,u_int nm_bay); |
|
|
|
|
|
/* Find a NIO binding */ |
|
|
struct c2600_nio_binding * |
|
|
c2600_nm_find_nio_binding(c2600_t *router,u_int nm_bay,u_int port_id); |
|
|
|
|
|
/* Add a network IO binding */ |
|
|
int c2600_nm_add_nio_binding(c2600_t *router,u_int nm_bay,u_int port_id, |
|
|
char *nio_name); |
|
|
|
|
|
/* Remove a NIO binding */ |
|
|
int c2600_nm_remove_nio_binding(c2600_t *router,u_int nm_bay,u_int port_id); |
|
|
|
|
|
/* Remove all NIO bindings for the specified NM */ |
|
|
int c2600_nm_remove_all_nio_bindings(c2600_t *router,u_int nm_bay); |
|
|
|
|
|
/* Enable a Network IO descriptor for a Network Module */ |
|
|
int c2600_nm_enable_nio(c2600_t *router,u_int nm_bay,u_int port_id); |
|
|
|
|
|
/* Disable Network IO descriptor of a Network Module */ |
|
|
int c2600_nm_disable_nio(c2600_t *router,u_int nm_bay,u_int port_id); |
|
|
|
|
|
/* Enable all NIO of the specified NM */ |
|
|
int c2600_nm_enable_all_nio(c2600_t *router,u_int nm_bay); |
|
|
|
|
|
/* Disable all NIO of the specified NM */ |
|
|
int c2600_nm_disable_all_nio(c2600_t *router,u_int nm_bay); |
|
|
|
|
|
/* Initialize a Network Module */ |
|
|
int c2600_nm_init(c2600_t *router,u_int nm_bay); |
|
|
|
|
|
/* Shutdown a Network Module */ |
|
|
int c2600_nm_shutdown(c2600_t *router,u_int nm_bay); |
|
|
|
|
|
/* Shutdown all NM of a router */ |
|
|
int c2600_nm_shutdown_all(c2600_t *router); |
|
|
|
|
|
/* Show info about all NMs */ |
|
|
int c2600_nm_show_all_info(c2600_t *router); |
|
|
|
|
|
/* Create a Network Module (command line) */ |
|
|
int c2600_cmd_nm_create(c2600_t *router,char *str); |
|
|
|
|
|
/* Add a Network IO descriptor binding (command line) */ |
|
|
int c2600_cmd_add_nio(c2600_t *router,char *str); |
|
|
|
|
|
/* Show the list of available NM drivers */ |
|
|
void c2600_nm_show_drivers(void); |
|
122 |
|
|
123 |
/* Set mainboard type */ |
/* Set mainboard type */ |
124 |
int c2600_mainboard_set_type(c2600_t *router,char *mainboard_type); |
int c2600_mainboard_set_type(c2600_t *router,char *mainboard_type); |
129 |
/* Show C2600 hardware info */ |
/* Show C2600 hardware info */ |
130 |
void c2600_show_hardware(c2600_t *router); |
void c2600_show_hardware(c2600_t *router); |
131 |
|
|
|
/* Initialize default parameters for a C2600 */ |
|
|
void c2600_init_defaults(c2600_t *router); |
|
|
|
|
|
/* Initialize the C2600 Platform */ |
|
|
int c2600_init_platform(c2600_t *router); |
|
|
|
|
|
/* Initialize a Cisco 2600 instance */ |
|
|
int c2600_init_instance(c2600_t *router); |
|
|
|
|
|
/* Stop a Cisco 2600 instance */ |
|
|
int c2600_stop_instance(c2600_t *router); |
|
|
|
|
132 |
/* Initialize EEPROM groups */ |
/* Initialize EEPROM groups */ |
133 |
void c2600_init_eeprom_groups(c2600_t *router); |
void c2600_init_eeprom_groups(c2600_t *router); |
134 |
|
|
140 |
/* dev_c2600_iofpga_init() */ |
/* dev_c2600_iofpga_init() */ |
141 |
int dev_c2600_iofpga_init(c2600_t *router,m_uint64_t paddr,m_uint32_t len); |
int dev_c2600_iofpga_init(c2600_t *router,m_uint64_t paddr,m_uint32_t len); |
142 |
|
|
143 |
|
/* Register the c2600 platform */ |
144 |
|
int c2600_platform_register(void); |
145 |
|
|
146 |
|
/* Hypervisor C2600 initialization */ |
147 |
|
extern int hypervisor_c2600_init(vm_platform_t *platform); |
148 |
|
|
149 |
/* NM drivers */ |
/* NM drivers */ |
150 |
extern struct c2600_nm_driver dev_c2600_mb1e_eth_driver; |
extern struct cisco_card_driver dev_c2600_mb1e_eth_driver; |
151 |
extern struct c2600_nm_driver dev_c2600_mb2e_eth_driver; |
extern struct cisco_card_driver dev_c2600_mb2e_eth_driver; |
152 |
extern struct c2600_nm_driver dev_c2600_mb1fe_eth_driver; |
extern struct cisco_card_driver dev_c2600_mb1fe_eth_driver; |
153 |
extern struct c2600_nm_driver dev_c2600_mb2fe_eth_driver; |
extern struct cisco_card_driver dev_c2600_mb2fe_eth_driver; |
154 |
|
|
155 |
extern struct c2600_nm_driver dev_c2600_nm_1e_driver; |
extern struct cisco_card_driver dev_c2600_nm_1e_driver; |
156 |
extern struct c2600_nm_driver dev_c2600_nm_4e_driver; |
extern struct cisco_card_driver dev_c2600_nm_4e_driver; |
157 |
extern struct c2600_nm_driver dev_c2600_nm_1fe_tx_driver; |
extern struct cisco_card_driver dev_c2600_nm_1fe_tx_driver; |
158 |
extern struct c2600_nm_driver dev_c2600_nm_16esw_driver; |
extern struct cisco_card_driver dev_c2600_nm_16esw_driver; |
159 |
|
|
160 |
|
extern struct cisco_card_driver dev_c2600_nm_nam_driver; |
161 |
|
extern struct cisco_card_driver dev_c2600_nm_cids_driver; |
162 |
|
|
163 |
|
/* WIC drivers */ |
164 |
|
extern struct cisco_card_driver *dev_c2600_mb_wic_drivers[]; |
165 |
|
|
166 |
#endif |
#endif |