ia64/xen-unstable
changeset 2192:cad129c5e1d8
bitkeeper revision 1.1159.17.12 (411a8de0-86ZTIpSwmzK3L2rrD65Nw)
Merge labyrinth.cl.cam.ac.uk:/auto/groups/xeno/BK/xeno.bk
into labyrinth.cl.cam.ac.uk:/auto/anfs/scratch/labyrinth/iap10/xeno-clone/xeno.bk
Merge labyrinth.cl.cam.ac.uk:/auto/groups/xeno/BK/xeno.bk
into labyrinth.cl.cam.ac.uk:/auto/anfs/scratch/labyrinth/iap10/xeno-clone/xeno.bk
author | iap10@labyrinth.cl.cam.ac.uk |
---|---|
date | Wed Aug 11 21:21:36 2004 +0000 (2004-08-11) |
parents | 8927b36dfcc0 e035c42a8e6f |
children | 85100363043c |
files | linux-2.4.26-xen-sparse/arch/xen/drivers/blkif/frontend/main.c linux-2.4.26-xen-sparse/arch/xen/kernel/setup.c linux-2.6.7-xen-sparse/drivers/xen/netback/interface.c linux-2.6.7-xen-sparse/drivers/xen/netfront/netfront.c |
line diff
1.1 --- a/linux-2.4.26-xen-sparse/arch/xen/drivers/blkif/frontend/main.c Wed Aug 11 18:08:19 2004 +0000 1.2 +++ b/linux-2.4.26-xen-sparse/arch/xen/drivers/blkif/frontend/main.c Wed Aug 11 21:21:36 2004 +0000 1.3 @@ -60,6 +60,34 @@ static int sg_operation = -1; 1.4 static unsigned long sg_next_sect; 1.5 #define DISABLE_SCATTERGATHER() (sg_operation = -1) 1.6 1.7 + 1.8 +inline void translate_req_to_pfn( blkif_request_t * xreq, blkif_request_t * req) 1.9 +{ 1.10 + int i; 1.11 + 1.12 + *xreq=*req; 1.13 + for ( i=0; i<req->nr_segments; i++ ) 1.14 + { 1.15 + xreq->frame_and_sects[i] = (req->frame_and_sects[i] & ~PAGE_MASK) | 1.16 + (machine_to_phys_mapping[req->frame_and_sects[i]>>PAGE_SHIFT]<<PAGE_SHIFT); 1.17 + } 1.18 + return xreq; 1.19 +} 1.20 + 1.21 +inline void translate_req_to_mfn( blkif_request_t * xreq, blkif_request_t * req) 1.22 +{ 1.23 + int i; 1.24 + 1.25 + *xreq=*req; 1.26 + for ( i=0; i<req->nr_segments; i++ ) 1.27 + { 1.28 + xreq->frame_and_sects[i] = (req->frame_and_sects[i] & ~PAGE_MASK) | 1.29 + (phys_to_machine_mapping[req->frame_and_sects[i]>>PAGE_SHIFT]<<PAGE_SHIFT); 1.30 + } 1.31 + return xreq; 1.32 +} 1.33 + 1.34 + 1.35 static inline void flush_requests(void) 1.36 { 1.37 DISABLE_SCATTERGATHER(); 1.38 @@ -364,8 +392,8 @@ static int blkif_queue_request(unsigned 1.39 DISABLE_SCATTERGATHER(); 1.40 1.41 /* Update the copy of the request in the recovery ring. */ 1.42 - blk_ring_rec->ring[MASK_BLKIF_IDX(blk_ring_rec->req_prod - 1)].req 1.43 - = *req; 1.44 + translate_req_to_pfn(&blk_ring_rec->ring[ 1.45 + MASK_BLKIF_IDX(blk_ring_rec->req_prod - 1)].req, req); 1.46 1.47 return 0; 1.48 } 1.49 @@ -395,8 +423,9 @@ static int blkif_queue_request(unsigned 1.50 req->frame_and_sects[0] = buffer_ma | (fsect<<3) | lsect; 1.51 req_prod++; 1.52 1.53 - /* Keep a private copy so we can reissue requests when recovering. */ 1.54 - blk_ring_rec->ring[MASK_BLKIF_IDX(blk_ring_rec->req_prod)].req = *req; 1.55 + /* Keep a private copy so we can reissue requests when recovering. */ 1.56 + translate_req_to_pfn(&blk_ring_rec->ring[ 1.57 + MASK_BLKIF_IDX(blk_ring_rec->req_prod)].req, req); 1.58 blk_ring_rec->req_prod++; 1.59 1.60 return 0; 1.61 @@ -570,9 +599,11 @@ void blkif_control_send(blkif_request_t 1.62 } 1.63 1.64 DISABLE_SCATTERGATHER(); 1.65 - memcpy(&blk_ring->ring[MASK_BLKIF_IDX(req_prod)].req, req, sizeof(*req)); 1.66 - memcpy(&blk_ring_rec->ring[MASK_BLKIF_IDX(blk_ring_rec->req_prod++)].req, 1.67 - req, sizeof(*req)); 1.68 + blk_ring->ring[MASK_BLKIF_IDX(req_prod)].req = *req; 1.69 + 1.70 + translate_req_to_pfn(&blk_ring_rec->ring[ 1.71 + MASK_BLKIF_IDX(blk_ring_rec->req_prod++)].req,req); 1.72 + 1.73 req_prod++; 1.74 flush_requests(); 1.75 1.76 @@ -660,7 +691,7 @@ static void blkif_status_change(blkif_fe 1.77 1.78 if ( recovery ) 1.79 { 1.80 - int i; 1.81 + int i,j; 1.82 1.83 /* Shouldn't need the io_request_lock here - the device is 1.84 * plugged and the recovery flag prevents the interrupt handler 1.85 @@ -670,18 +701,24 @@ static void blkif_status_change(blkif_fe 1.86 for ( i = 0; 1.87 resp_cons_rec < blk_ring_rec->req_prod; 1.88 resp_cons_rec++, i++ ) 1.89 - { 1.90 - blk_ring->ring[i].req 1.91 - = blk_ring_rec->ring[MASK_BLKIF_IDX(resp_cons_rec)].req; 1.92 + { 1.93 + translate_req_to_mfn(&blk_ring->ring[i].req, 1.94 + &blk_ring_rec->ring[ 1.95 + MASK_BLKIF_IDX(resp_cons_rec)].req); 1.96 } 1.97 1.98 - /* Reset the private block ring to match the new ring. */ 1.99 - memcpy(blk_ring_rec, blk_ring, sizeof(*blk_ring)); 1.100 + /* Reset the private block ring to match the new ring. */ 1.101 + for( j=0; j<i; j++ ) 1.102 + { 1.103 + translate_req_to_pfn( 1.104 + &blk_ring_rec->ring[j].req, 1.105 + &blk_ring->ring[j].req); 1.106 + } 1.107 + 1.108 resp_cons_rec = 0; 1.109 1.110 /* blk_ring->req_prod will be set when we flush_requests().*/ 1.111 blk_ring_rec->req_prod = req_prod = i; 1.112 - 1.113 wmb(); 1.114 1.115 /* Switch off recovery mode, using a memory barrier to ensure that 1.116 @@ -806,8 +843,7 @@ void blkdev_suspend(void) 1.117 void blkdev_resume(void) 1.118 { 1.119 ctrl_msg_t cmsg; 1.120 - blkif_fe_driver_status_changed_t st; 1.121 - 1.122 + blkif_fe_driver_status_changed_t st; 1.123 1.124 /* Send a driver-UP notification to the domain controller. */ 1.125 cmsg.type = CMSG_BLKIF_FE;
2.1 --- a/linux-2.4.26-xen-sparse/arch/xen/kernel/setup.c Wed Aug 11 18:08:19 2004 +0000 2.2 +++ b/linux-2.4.26-xen-sparse/arch/xen/kernel/setup.c Wed Aug 11 21:21:36 2004 +0000 2.3 @@ -1197,11 +1197,12 @@ static int shutting_down = -1; 2.4 2.5 static void __do_suspend(void) 2.6 { 2.7 + int i,j; 2.8 /* Hmmm... a cleaner interface to suspend/resume blkdevs would be nice. */ 2.9 extern void blkdev_suspend(void); 2.10 extern void blkdev_resume(void); 2.11 - extern void netif_resume(void); 2.12 - 2.13 + extern void netif_suspend(void); 2.14 + extern void netif_resume(void); 2.15 extern void time_suspend(void); 2.16 extern void time_resume(void); 2.17 2.18 @@ -1213,10 +1214,11 @@ static void __do_suspend(void) 2.19 2.20 suspend_record->nr_pfns = max_pfn; /* final number of pfns */ 2.21 2.22 - //netdev_suspend(); 2.23 - //blkdev_suspend(); 2.24 + __cli(); 2.25 2.26 - __cli(); 2.27 + netif_suspend(); 2.28 + 2.29 + blkdev_suspend(); 2.30 2.31 time_suspend(); 2.32 2.33 @@ -1241,16 +1243,27 @@ static void __do_suspend(void) 2.34 2.35 memset(empty_zero_page, 0, PAGE_SIZE); 2.36 2.37 + for ( i=0, j=0; i < max_pfn; i+=(PAGE_SIZE/sizeof(unsigned long)), j++ ) 2.38 + { 2.39 + pfn_to_mfn_frame_list[j] = 2.40 + virt_to_machine(&phys_to_machine_mapping[i]) >> PAGE_SHIFT; 2.41 + } 2.42 + HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list = 2.43 + virt_to_machine(pfn_to_mfn_frame_list) >> PAGE_SHIFT; 2.44 + 2.45 + 2.46 irq_resume(); 2.47 2.48 ctrl_if_resume(); 2.49 2.50 time_resume(); 2.51 2.52 + blkdev_resume(); 2.53 + 2.54 + netif_resume(); 2.55 + 2.56 __sti(); 2.57 2.58 - blkdev_resume(); 2.59 - netif_resume(); 2.60 2.61 out: 2.62 if ( suspend_record != NULL )
3.1 --- a/linux-2.6.7-xen-sparse/drivers/xen/netback/interface.c Wed Aug 11 18:08:19 2004 +0000 3.2 +++ b/linux-2.6.7-xen-sparse/drivers/xen/netback/interface.c Wed Aug 11 21:21:36 2004 +0000 3.3 @@ -241,6 +241,8 @@ void netif_connect(netif_be_connect_t *c 3.4 netif->status = CONNECTED; 3.5 netif_get(netif); 3.6 3.7 + netif->tx->resp_prod = netif->rx->resp_prod = 0; 3.8 + 3.9 rtnl_lock(); 3.10 (void)dev_open(netif->dev); 3.11 rtnl_unlock();
4.1 --- a/linux-2.6.7-xen-sparse/drivers/xen/netfront/netfront.c Wed Aug 11 18:08:19 2004 +0000 4.2 +++ b/linux-2.6.7-xen-sparse/drivers/xen/netfront/netfront.c Wed Aug 11 21:21:36 2004 +0000 4.3 @@ -546,7 +546,7 @@ static void network_connect(struct net_d 4.4 4.5 /* Step 1: Reinitialise variables. */ 4.6 np->rx_resp_cons = np->tx_resp_cons = np->tx_full = 0; 4.7 - np->rx->event = 1; 4.8 + np->rx->event = np->tx->event = 1; 4.9 4.10 /* Step 2: Rebuild the RX and TX ring contents. 4.11 * NB. We could just free the queued TX packets now but we hope 4.12 @@ -776,12 +776,13 @@ static int create_netdev(int handle, str 4.13 * Initialize the network control interface. Set the number of network devices 4.14 * and create them. 4.15 */ 4.16 + 4.17 static void netif_driver_status_change( 4.18 netif_fe_driver_status_changed_t *status) 4.19 { 4.20 int err = 0; 4.21 int i; 4.22 - 4.23 + 4.24 netctrl.interface_n = status->nr_interfaces; 4.25 netctrl.connected_n = 0; 4.26 4.27 @@ -874,11 +875,75 @@ static int __init netif_init(void) 4.28 return err; 4.29 } 4.30 4.31 +void netif_suspend(void) 4.32 +{ 4.33 +#if 1 /* XXX THIS IS TEMPORARY */ 4.34 + struct net_device *dev = NULL; 4.35 + struct net_private *np = NULL; 4.36 + int i; 4.37 + 4.38 +/* avoid having tx/rx stuff happen until we're ready */ 4.39 + 4.40 + for(i=0;i<netctrl.interface_n;i++) 4.41 + { 4.42 + char name[32]; 4.43 + 4.44 + sprintf(name,"eth%d",i); 4.45 + dev = __dev_get_by_name(name); 4.46 + 4.47 + if ( dev && (dev->flags & IFF_UP) ) 4.48 + { 4.49 + np = dev->priv; 4.50 + 4.51 + free_irq(np->irq, dev); 4.52 + unbind_evtchn_from_irq(np->evtchn); 4.53 + } 4.54 + } 4.55 +#endif 4.56 +} 4.57 + 4.58 void netif_resume(void) 4.59 { 4.60 ctrl_msg_t cmsg; 4.61 - netif_fe_driver_status_changed_t st; 4.62 + netif_fe_interface_connect_t up; 4.63 +// netif_fe_driver_status_changed_t st; 4.64 + struct net_device *dev = NULL; 4.65 + struct net_private *np = NULL; 4.66 + int i; 4.67 + 4.68 +#if 1 4.69 + /* XXX THIS IS TEMPORARY */ 4.70 + 4.71 + for(i=0;i<netctrl.interface_n;i++) 4.72 + { 4.73 + char name[32]; 4.74 + 4.75 + sprintf(name,"eth%d",i); 4.76 + dev = __dev_get_by_name(name); 4.77 + 4.78 + if ( dev ) // connect regardless of whether IFF_UP flag set 4.79 + { 4.80 + np = dev->priv; 4.81 4.82 + // stop bad things from happening until we're back up 4.83 + np->backend_state = BEST_DISCONNECTED; 4.84 + 4.85 + cmsg.type = CMSG_NETIF_FE; 4.86 + cmsg.subtype = CMSG_NETIF_FE_INTERFACE_CONNECT; 4.87 + cmsg.length = sizeof(netif_fe_interface_connect_t); 4.88 + up.handle = np->handle; 4.89 + up.tx_shmem_frame = virt_to_machine(np->tx) >> PAGE_SHIFT; 4.90 + up.rx_shmem_frame = virt_to_machine(np->rx) >> PAGE_SHIFT; 4.91 + memcpy(cmsg.msg, &up, sizeof(up)); 4.92 + 4.93 + /* Tell the controller to bring up the interface. */ 4.94 + ctrl_if_send_message_block(&cmsg, NULL, 0, TASK_UNINTERRUPTIBLE); 4.95 + } 4.96 + } 4.97 +#endif 4.98 + 4.99 + 4.100 +#if 0 4.101 /* Send a driver-UP notification to the domain controller. */ 4.102 cmsg.type = CMSG_NETIF_FE; 4.103 cmsg.subtype = CMSG_NETIF_FE_DRIVER_STATUS_CHANGED; 4.104 @@ -887,6 +952,8 @@ void netif_resume(void) 4.105 st.nr_interfaces = 0; 4.106 memcpy(cmsg.msg, &st, sizeof(st)); 4.107 ctrl_if_send_message_block(&cmsg, NULL, 0, TASK_UNINTERRUPTIBLE); 4.108 +#endif 4.109 + 4.110 4.111 } 4.112