ia64/xen-unstable

changeset 213:3f4a788e4e0d

bitkeeper revision 1.73 (3e54a504I0R16H6sLQWoyBCN8RPwAg)

Merge boulderdash.cl.cam.ac.uk:/auto/groups/xeno/BK/xeno
into boulderdash.cl.cam.ac.uk:/auto/anfs/scratch/boulderdash/akw27/argh/xeno
author akw27@boulderdash.cl.cam.ac.uk
date Thu Feb 20 09:51:00 2003 +0000 (2003-02-20)
parents 35546c6bf1bd ce5fb53e847b
children 2e78c0d979ec
files xen-2.4.16/common/network.c xen-2.4.16/include/hypervisor-ifs/network.h xenolinux-2.4.16-sparse/arch/xeno/drivers/dom0/dom0_core.c
line diff
     1.1 --- a/xen-2.4.16/common/network.c	Wed Feb 19 20:26:12 2003 +0000
     1.2 +++ b/xen-2.4.16/common/network.c	Thu Feb 20 09:51:00 2003 +0000
     1.3 @@ -18,6 +18,8 @@
     1.4  #include <linux/skbuff.h>
     1.5  #include <xeno/netdevice.h>
     1.6  #include <xeno/in.h>
     1.7 +#include <asm/domain_page.h>
     1.8 +#include <asm/io.h>
     1.9  
    1.10  /* vif globals 
    1.11   * sys_vif_list is a lookup table for vifs, used in packet forwarding.
    1.12 @@ -128,6 +130,33 @@ void destroy_net_vif(struct task_struct 
    1.13      kmem_cache_free(net_vif_cache, p->net_vif_list[i]);
    1.14  }
    1.15  
    1.16 +/* vif_query - Call from the proc file system to get a list of vifs 
    1.17 + * assigned to a particular domain.
    1.18 + */
    1.19 +
    1.20 +void vif_query(vif_query_t *vq)
    1.21 +{
    1.22 +    struct task_struct *dom_task;
    1.23 +    char buf[128];
    1.24 +    int i;
    1.25 +
    1.26 +    if ( !(dom_task = find_domain_by_id(vq->domain)) )
    1.27 +    {
    1.28 +        return;
    1.29 +    }
    1.30 +
    1.31 +    *buf = '\0';
    1.32 +
    1.33 +    for (i=0; i < dom_task->num_net_vifs; i++)
    1.34 +    {
    1.35 +        sprintf(buf + strlen(buf), "%d\n", dom_task->net_vif_list[i]->id);
    1.36 +    }
    1.37 +
    1.38 +    copy_to_user(vq->buf, buf, strlen(buf) + 1);
    1.39 +    
    1.40 +}
    1.41 +        
    1.42 +
    1.43  /* print_vif_list - Print the contents of the global vif table.
    1.44   */
    1.45  
    1.46 @@ -426,6 +455,11 @@ long do_network_op(network_op_t *u_netwo
    1.47          print_net_rule_list();
    1.48      }
    1.49      break;
    1.50 +
    1.51 +    case NETWORK_OP_VIFQUERY:
    1.52 +    {
    1.53 +        vif_query(&op.u.vif_query);
    1.54 +    }
    1.55      
    1.56      default:
    1.57          ret = -ENOSYS;
     2.1 --- a/xen-2.4.16/include/hypervisor-ifs/network.h	Wed Feb 19 20:26:12 2003 +0000
     2.2 +++ b/xen-2.4.16/include/hypervisor-ifs/network.h	Thu Feb 20 09:51:00 2003 +0000
     2.3 @@ -84,6 +84,12 @@ typedef struct net_rule_st
     2.4      u16  action;
     2.5  } net_rule_t;
     2.6  
     2.7 +typedef struct vif_query_st
     2.8 +{
     2.9 +    unsigned int    domain;
    2.10 +    char            *buf;   // where to put the reply -- guest virtual address
    2.11 +} vif_query_t;
    2.12 +
    2.13  /* Network trap operations and associated structure. 
    2.14   * This presently just handles rule insertion and deletion, but will
    2.15   * evenually have code to add and remove interfaces.
    2.16 @@ -92,6 +98,7 @@ typedef struct net_rule_st
    2.17  #define NETWORK_OP_ADDRULE      0
    2.18  #define NETWORK_OP_DELETERULE   1
    2.19  #define NETWORK_OP_GETRULELIST  2
    2.20 +#define NETWORK_OP_VIFQUERY     3
    2.21  
    2.22  typedef struct network_op_st 
    2.23  {
    2.24 @@ -99,6 +106,7 @@ typedef struct network_op_st
    2.25      union
    2.26      {
    2.27          net_rule_t net_rule;
    2.28 +        vif_query_t vif_query;
    2.29      }
    2.30      u;
    2.31  } network_op_t;
     3.1 --- a/xenolinux-2.4.16-sparse/arch/xeno/drivers/dom0/dom0_core.c	Wed Feb 19 20:26:12 2003 +0000
     3.2 +++ b/xenolinux-2.4.16-sparse/arch/xeno/drivers/dom0/dom0_core.c	Thu Feb 20 09:51:00 2003 +0000
     3.3 @@ -49,6 +49,7 @@ typedef struct proc_mem_data {
     3.4  #define MAX_LEN         16
     3.5  #define DOM_DIR         "dom"
     3.6  #define DOM_MEM         "mem"
     3.7 +#define DOM_VIF         "vif"
     3.8  
     3.9  #define MAP_DISCONT     1
    3.10  
    3.11 @@ -72,11 +73,50 @@ static int cmd_read_proc(char *page, cha
    3.12      return strlen(page);
    3.13  }
    3.14  
    3.15 +static ssize_t dom_vif_read(struct file * file, char * buff, size_t size, loff_t * off)
    3.16 +{
    3.17 +    char hyp_buf[128]; // Hypervisor is going to write its reply here.
    3.18 +    network_op_t op;
    3.19 +    static int finished = 0;
    3.20 +
    3.21 +    // This seems to be the only way to make the OS stop making read requests
    3.22 +    // to the file.  When we use the fileoperations version of read, offset 
    3.23 +    // seems to be ignored altogether.
    3.24 +    
    3.25 +    if (finished) 
    3.26 +    {
    3.27 +        finished = 0;
    3.28 +        return 0;
    3.29 +    }
    3.30 +    
    3.31 +    op.cmd = NETWORK_OP_VIFQUERY;
    3.32 +    op.u.vif_query.domain = (unsigned int) ((struct proc_dir_entry *)file->f_dentry->d_inode->u.generic_ip)->data;
    3.33 +    op.u.vif_query.buf = hyp_buf;
    3.34 +
    3.35 +    strcpy(hyp_buf, "Error getting domain's vif list from hypervisor.\n"); // This will be replaced if everything works.
    3.36 +
    3.37 +    (void)HYPERVISOR_network_op(&op);
    3.38 +
    3.39 +    if (*off >= (strlen(hyp_buf)+1)) return 0;
    3.40 +    
    3.41 +    copy_to_user(buff, hyp_buf, strlen(hyp_buf));
    3.42 +    
    3.43 +    finished = 1;
    3.44 +    
    3.45 +    return strlen(hyp_buf)+1;
    3.46 +}
    3.47 +
    3.48 +struct file_operations dom_vif_ops = {
    3.49 +    read:    dom_vif_read
    3.50 +};
    3.51 +
    3.52 +
    3.53  static void create_proc_dom_entries(int dom)
    3.54  {
    3.55      struct proc_dir_entry * dir;
    3.56      dom_procdata_t * dom_data;
    3.57      char dir_name[MAX_LEN];
    3.58 +    struct proc_dir_entry * file;
    3.59  
    3.60      snprintf(dir_name, MAX_LEN, "%s%d", DOM_DIR, dom);
    3.61  
    3.62 @@ -85,6 +125,15 @@ static void create_proc_dom_entries(int 
    3.63  
    3.64      dir = proc_mkdir(dir_name, xeno_base);
    3.65      dir->data = dom_data;
    3.66 +    
    3.67 +    file = create_proc_entry(DOM_VIF, 0600, dir);
    3.68 +    if (file != NULL)
    3.69 +    {
    3.70 +        file->owner         = THIS_MODULE;
    3.71 +        file->nlink         = 1;
    3.72 +        file->proc_fops     = &dom_vif_ops;
    3.73 +        file->data          = (void *) dom;
    3.74 +    }
    3.75  }
    3.76  
    3.77  static ssize_t dom_mem_write(struct file * file, const char * buff, 
    3.78 @@ -159,6 +208,7 @@ static int dom_map_mem(unsigned int dom,
    3.79                  ret = 0;
    3.80                  break;
    3.81              }
    3.82 +
    3.83              ret = -EAGAIN;
    3.84              break;
    3.85          }