| 1 |
/* |
| 2 |
* Cisco router simulation platform. |
| 3 |
* Copyright (c) 2007 Christophe Fillot ([email protected]) |
| 4 |
* |
| 5 |
* Cisco 1700 Mainboard Ethernet driver. |
| 6 |
*/ |
| 7 |
|
| 8 |
#include <stdio.h> |
| 9 |
#include <stdlib.h> |
| 10 |
#include <string.h> |
| 11 |
#include <stdarg.h> |
| 12 |
#include <unistd.h> |
| 13 |
#include <time.h> |
| 14 |
#include <errno.h> |
| 15 |
#include <assert.h> |
| 16 |
|
| 17 |
#include "utils.h" |
| 18 |
#include "net.h" |
| 19 |
#include "net_io.h" |
| 20 |
#include "ptask.h" |
| 21 |
#include "vm.h" |
| 22 |
#include "dev_mpc860.h" |
| 23 |
#include "dev_c1700.h" |
| 24 |
|
| 25 |
/* Return sub-slot info for integrated WIC slots (on motherboard) */ |
| 26 |
static int dev_c1700_mb_get_sub_info(vm_instance_t *vm,struct cisco_card *card, |
| 27 |
u_int port_id, |
| 28 |
struct cisco_card_driver ***drv_array, |
| 29 |
u_int *subcard_type) |
| 30 |
{ |
| 31 |
/* 2 integrated WIC slots */ |
| 32 |
if ((port_id & 0x0F) >= 2) |
| 33 |
return(-1); |
| 34 |
|
| 35 |
*drv_array = dev_c1700_mb_wic_drivers; |
| 36 |
*subcard_type = CISCO_CARD_TYPE_WIC; |
| 37 |
return(0); |
| 38 |
} |
| 39 |
|
| 40 |
/* ====================================================================== */ |
| 41 |
/* MPC860 - Integrated Ethernet port */ |
| 42 |
/* ====================================================================== */ |
| 43 |
|
| 44 |
/* Initialize Ethernet part of the MPC860 */ |
| 45 |
static int dev_c1700_mb_eth_init(vm_instance_t *vm,struct cisco_card *card) |
| 46 |
{ |
| 47 |
if (card->slot_id != 0) { |
| 48 |
vm_error(vm,"dev_c1700_mb_eth_init: bad slot %u specified.\n", |
| 49 |
card->slot_id); |
| 50 |
return(-1); |
| 51 |
} |
| 52 |
|
| 53 |
/* Store device info into the router structure */ |
| 54 |
card->drv_info = VM_C1700(vm)->mpc_data; |
| 55 |
return(0); |
| 56 |
} |
| 57 |
|
| 58 |
/* Nothing to do, we never remove the system controller */ |
| 59 |
static int dev_c1700_mb_eth_shutdown(vm_instance_t *vm,struct cisco_card *card) |
| 60 |
{ |
| 61 |
return(0); |
| 62 |
} |
| 63 |
|
| 64 |
/* Bind a Network IO descriptor */ |
| 65 |
static int dev_c1700_mb_eth_set_nio(vm_instance_t *vm,struct cisco_card *card, |
| 66 |
u_int port_id,netio_desc_t *nio) |
| 67 |
{ |
| 68 |
struct mpc860_data *d = card->drv_info; |
| 69 |
|
| 70 |
if (port_id != 0) |
| 71 |
return(-1); |
| 72 |
|
| 73 |
return(mpc860_fec_set_nio(d,nio)); |
| 74 |
} |
| 75 |
|
| 76 |
/* Unbind a Network IO descriptor */ |
| 77 |
static int dev_c1700_mb_eth_unset_nio(vm_instance_t *vm, |
| 78 |
struct cisco_card *card, |
| 79 |
u_int port_id) |
| 80 |
{ |
| 81 |
struct mpc860_data *d = card->drv_info; |
| 82 |
|
| 83 |
if (port_id != 0) |
| 84 |
return(-1); |
| 85 |
|
| 86 |
return(mpc860_fec_unset_nio(d)); |
| 87 |
} |
| 88 |
|
| 89 |
/* c1700 Motherboard driver */ |
| 90 |
struct cisco_card_driver dev_c1700_mb_eth_driver = { |
| 91 |
"C1700-MB-1ETH", 1, 2, |
| 92 |
dev_c1700_mb_eth_init, |
| 93 |
dev_c1700_mb_eth_shutdown, |
| 94 |
dev_c1700_mb_get_sub_info, |
| 95 |
dev_c1700_mb_eth_set_nio, |
| 96 |
dev_c1700_mb_eth_unset_nio, |
| 97 |
NULL, |
| 98 |
}; |
| 99 |
|
| 100 |
/* ====================================================================== */ |
| 101 |
/* C1710: 1 FastEthernet port + 1 Ethernet port as SCC channel 1. */ |
| 102 |
/* ====================================================================== */ |
| 103 |
|
| 104 |
/* Bind a Network IO descriptor */ |
| 105 |
static int dev_c1710_mb_eth_set_nio(vm_instance_t *vm,struct cisco_card *card, |
| 106 |
u_int port_id,netio_desc_t *nio) |
| 107 |
{ |
| 108 |
struct mpc860_data *d = card->drv_info; |
| 109 |
|
| 110 |
switch(port_id) { |
| 111 |
case 0: |
| 112 |
return(mpc860_fec_set_nio(d,nio)); |
| 113 |
case 1: |
| 114 |
return(mpc860_scc_set_nio(d,0,nio)); |
| 115 |
default: |
| 116 |
return(-1); |
| 117 |
} |
| 118 |
} |
| 119 |
|
| 120 |
/* Unbind a Network IO descriptor */ |
| 121 |
static int dev_c1710_mb_eth_unset_nio(vm_instance_t *vm, |
| 122 |
struct cisco_card *card, |
| 123 |
u_int port_id) |
| 124 |
{ |
| 125 |
struct mpc860_data *d = card->drv_info; |
| 126 |
|
| 127 |
switch(port_id) { |
| 128 |
case 0: |
| 129 |
return(mpc860_fec_unset_nio(d)); |
| 130 |
case 1: |
| 131 |
return(mpc860_scc_unset_nio(d,0)); |
| 132 |
default: |
| 133 |
return(-1); |
| 134 |
} |
| 135 |
} |
| 136 |
|
| 137 |
/* c1710 Motherboard driver */ |
| 138 |
struct cisco_card_driver dev_c1710_mb_eth_driver = { |
| 139 |
"C1710-MB-1FE-1E", 1, 0, |
| 140 |
dev_c1700_mb_eth_init, |
| 141 |
dev_c1700_mb_eth_shutdown, |
| 142 |
NULL, |
| 143 |
dev_c1710_mb_eth_set_nio, |
| 144 |
dev_c1710_mb_eth_unset_nio, |
| 145 |
NULL, |
| 146 |
}; |
| 147 |
|