PERFORCE change 179777 for review
Alexandre Fiveg
afiveg at FreeBSD.org
Fri Jun 18 17:57:03 UTC 2010
http://p4web.freebsd.org/@@179777?ac=10
Change 179777 by afiveg at cottonmouth on 2010/06/18 17:56:52
Continue working on new ringmap designe + user-space tetst programms.
open.c - for opening ringmap char device. The next task: read system
messages to chek if it works in kernel space correctly
close.c - only for closing device. The next task: reading system messages.
mmap.c - in progress
Affected files ...
.. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/if_lem.c#5 edit
.. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/if_lem.h#5 edit
.. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/ringmap_8254.c#3 edit
.. //depot/projects/soc2010/ringmap/current/sys/dev/e1000/ringmap_e1000.h#4 edit
.. //depot/projects/soc2010/ringmap/current/sys/modules/ringmap/Makefile#1 add
.. //depot/projects/soc2010/ringmap/current/sys/net/ringmap.c#7 edit
.. //depot/projects/soc2010/ringmap/current/sys/net/ringmap.h#7 edit
.. //depot/projects/soc2010/ringmap/tests/README#1 add
.. //depot/projects/soc2010/ringmap/tests/ringmap/Makefile#1 add
.. //depot/projects/soc2010/ringmap/tests/ringmap/close.c#1 add
.. //depot/projects/soc2010/ringmap/tests/ringmap/main.c#1 add
.. //depot/projects/soc2010/ringmap/tests/ringmap/mmap.c#1 add
.. //depot/projects/soc2010/ringmap/tests/ringmap/open.c#1 add
.. //depot/projects/soc2010/ringmap/tests/ringmap/test#1 add
.. //depot/projects/soc2010/ringmap/tests/ringmap/tests.h#1 add
Differences ...
==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/if_lem.c#5 (text+ko) ====
==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/if_lem.h#5 (text+ko) ====
==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/ringmap_8254.c#3 (text+ko) ====
@@ -1,6 +1,7 @@
#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
+#include <sys/conf.h>
#include <sys/taskqueue.h>
#include <machine/bus.h>
@@ -17,6 +18,31 @@
int rm_8254_set_ringmap_to_adapter(device_t, struct ringmap *);
struct ringmap * rm_8254_get_ringmap_p(device_t);
+device_t rm_8254_get_device_p(struct cdev *);
+
+
+extern devclass_t em_devclass;
+
+/*
+ * Get pointer to device structure of adapter using our ringmap char device.
+ * This is a trick :) Our cdev must have the same unit number as dev of adapter.
+ * Look in ringmap.c: ringmap_attach() where we create our cdev.
+ */
+device_t
+rm_8254_get_device_p(struct cdev *cdev)
+{
+ struct adapter *adapter;
+
+ adapter = (struct adapter *)devclass_get_softc(em_devclass, dev2unit(cdev));
+#ifdef __RINGMAP_DEB
+ if (adapter == NULL){
+ RINGMAP_WARN(Can not get pointer to adapter structure);
+ }
+#endif
+
+ return (adapter->dev);
+}
+
/*
* Set pointer to ringmap in the adapter structure.
==== //depot/projects/soc2010/ringmap/current/sys/dev/e1000/ringmap_e1000.h#4 (text+ko) ====
==== //depot/projects/soc2010/ringmap/current/sys/net/ringmap.c#7 (text+ko) ====
@@ -42,13 +42,15 @@
int ringmap_attach (device_t);
int ringmap_detach (device_t);
int is_supported (unsigned int pci_dev_id);
+int set_ringmap_funcs (struct ringmap *rm, unsigned int controller_type);
void ringmap_close_cb (void *data);
-int set_ringmap_funcs (struct ringmap *rm, unsigned int controller_type);
+
struct ringmap *(*get_ringmap_p)(device_t);
+device_t (*get_device_p)(struct cdev *);
extern int rm_8254_set_ringmap_to_adapter(device_t, struct ringmap *);
extern struct ringmap * rm_8254_get_ringmap_p(device_t);
-
+extern device_t rm_8254_get_device_p(struct cdev *);
//struct adapter* get_adapter_struct(struct cdev *dev);
//int ringmap_print_ring_pointers(struct adapter *);
@@ -124,6 +126,7 @@
rm->funcs->set_ringmap_to_adapter =
rm_8254_set_ringmap_to_adapter;
get_ringmap_p = rm_8254_get_ringmap_p;
+ get_device_p = rm_8254_get_device_p;
break;
case 8257:
@@ -204,7 +207,7 @@
UID_ROOT, GID_WHEEL, 0666, RINGMAP_DEVICE);
/* Device open counter */
- rm->open_cnt = 0;
+ rm->open_cnt = 1;
/* Pointer to structure of process wich has opened the device */
rm->td = NULL;
@@ -222,20 +225,20 @@
int
-ringmap_detach(device_t devt)
+ringmap_detach(device_t dev)
{
-
struct ringmap *rm = NULL;
RINGMAP_FUNC_DEBUG(start);
- rm = get_ringmap_p (devt);
+ rm = get_ringmap_p (dev);
if (rm == NULL){
RINGMAP_WARN(Can not get pointer to ringmap structure);
return (-1);
}
destroy_dev(rm->cdev);
+
contigfree(rm->ring, sizeof(struct ring), M_DEVBUF);
contigfree(rm->funcs, sizeof(struct ringmap_functions), M_DEVBUF);
contigfree(rm, sizeof(struct ringmap), M_DEVBUF);
@@ -253,19 +256,23 @@
* be placed and accesseble in this user proccess.
******************************************************************/
int
-ringmap_open(struct cdev *dev, int flag, int otyp, struct thread *td)
+ringmap_open(struct cdev *cdev, int flag, int otyp, struct thread *td)
{
// unsigned int i;
// struct ring_slot;
// struct adapter *adapter = (struct adapter *)get_adapter_struct(dev);
-// struct ringmap *rm = adapter->rm;
+ struct ringmap *rm = NULL;
RINGMAP_FUNC_DEBUG(start);
#if (__RINGMAP_DEB)
printf("[%s]: dev_t=%d, flag=%x, otyp=%x\n",
- __func__, dev2udev(dev), flag, otyp);
-#endif
+ __func__, dev2udev(cdev), flag, otyp);
+#endif
+
+ /* Now magic */
+ rm = get_ringmap_p(get_device_p(cdev));
+ printf("[%s] open counter: %d\n", __func__, rm->open_cnt);
//
// /**
==== //depot/projects/soc2010/ringmap/current/sys/net/ringmap.h#7 (text+ko) ====
@@ -8,24 +8,23 @@
#define SLOTS_NUMBER 16
/* Prefix for name of device (for example /dev/ringmap_cdev_0 will full name) */
-#define RINGMAP_DEVICE "ringmap_cdev"
+#define RINGMAP_DEVICE "ringmap_cdev"
/* Name of module to be loaded*/
-#define MOD_NAME "if_ringmap.ko"
+#define MOD_NAME "if_ringmap.ko"
/* Messaure statistics for each pkt */
#define EACH_PKT 20
-/* Driver have to work only with device wich has the following device ID
- * if 0 then work with all devices that was found
+/*
+ * Driver have to work only with device wich has the following device ID if 0
+ * then work with all devices that was found and accepted in the "probe"
+ * function.
+ *
+ * #define DEV_ID 0x105E
*/
-// #define DEV_ID 0x105E
#define DEV_ID 0
-struct device_type {
- unsigned int pci_device_id;
- unsigned int controller_type;
-};
struct address {
bus_addr_t phys;
@@ -37,15 +36,15 @@
* This structure represents the ring slot.
*/
struct ring_slot {
+
struct address descriptor;
struct address mbuf;
struct address packet;
+ /**
+ ** Next fields are for statistics:
+ **/
- /*
- * Next fields are for statistics
- */
-
/* Time stamp of packet which placed in the slot */
struct timeval ts;
@@ -110,8 +109,13 @@
#ifdef _KERNEL
struct ringmap_functions;
+struct device_type {
+ unsigned int pci_device_id;
+ unsigned int controller_type;
+};
+
struct ringmap {
- /* Device structure of network adapters driver */
+ /* Device structure of network adapters */
device_t devt;
/* Char device for communications between user and kernel spaces */
@@ -226,8 +230,9 @@
*/
#endif
+
/*
- * D E B U G O U T P U T
+ * DEBUG OUTPUT
*/
#ifndef IOCTL_DEB
#define IOCTL_DEB 0
More information about the p4-projects
mailing list