Intel PCI User Manual

Page of 54
GigMAC-PMC and PCI 
GigPMC Switch  
 
Board and Driver Users Manual 
DSS NETWORKS, INC. 
Version: 2.6 
  Page: 46 
 
A. Opening a socket for management API 
 
 int 
s; 
s = socket (PF_INET, SOCK_STREAM, 0); 
 
 
B. Create request block for driver ioctl 
 
      struct ifreq ifr; 
      int subCmd; 
      NpkUserCtl myIoc; 
char myDataBuf[MAX_LINES * MAX_LINE_LEN]; 
 
 
/* set interface name */ 
      strcpy (ifr.ifr_name, “eth1”); 
 
 
/* set ioctl sub-type */ 
      subCmd = DM_IOCTL_GET_STATS; 
 
 
/* set command argument */ 
myIoc.arg1 = 0; 
 
myIoc.dataItm = (u_int) myDataBuf; 
ifr.ifr_data = (char *) &myIoc; 
 
 
 
C. Issue ioctl command  
 
 
/* issue ioctl to network driver */ 
      err = ioctl (s, SIOCDEVPRIVATE + subCmd, &ifr); 
 
 
D. Check and print results 
 
    if (err < 0) 
    { 
        /* perror (errno); */ 
        usage (); 
        exit (1); 
    } 
    if (subCmd == DM_IOCTL_GET_TRC) 
    { 
        print_trace(); 
    } 
    else 
    { 
        if ((subCmd != DM_IOCTL_SET_LOOP_MODE) &&  
            (subCmd != DM_IOCTL_PROG_EEPROM)) 
            printf ("\n%s\n", myDataBuf); 
    } 
 
IOCTL COMMAND SUB-TYPES