]> rtime.felk.cvut.cz Git - lincan.git/blobdiff - lincan/src/can_queue.c
Structured comments updated.
[lincan.git] / lincan / src / can_queue.c
index c0f1a6dc7e0a8926c5670dd6103115f5c99e7fe2..b0c027e9be1cde3fb9a3142401dfaee44f115c61 100644 (file)
@@ -21,9 +21,10 @@ extern int processlocal;
 atomic_t edge_num_cnt;
 
 //#define CAN_DEBUG
 atomic_t edge_num_cnt;
 
 //#define CAN_DEBUG
+#undef CAN_DEBUG
 
 #ifdef CAN_DEBUG
 
 #ifdef CAN_DEBUG
-       #define DEBUGQUE(fmt,args...) printk(KERN_ERR "can_queue (debug): " fmt,\
+       #define DEBUGQUE(fmt,args...) can_printk(KERN_ERR "can_queue (debug): " fmt,\
        ##args)
 
 #else
        ##args)
 
 #else
@@ -65,21 +66,17 @@ int canque_fifo_flush_slots(struct canque_fifo_t *fifo)
 
 
 /**
 
 
 /**
- * canque_fifo_init_slots - initialize one CAN FIFO
+ * canque_fifo_init_slots - initializes slot chain of one CAN FIFO
  * @fifo: pointer to the FIFO structure
  * @fifo: pointer to the FIFO structure
- * @slotsnr: number of requested slots
  *
  * Return Value: The negative value indicates, that there is no memory
  *     to allocate space for the requested number of the slots.
  */
  *
  * Return Value: The negative value indicates, that there is no memory
  *     to allocate space for the requested number of the slots.
  */
-int canque_fifo_init_slots(struct canque_fifo_t *fifo, int slotsnr)
+int canque_fifo_init_slots(struct canque_fifo_t *fifo)
 {
 {
-       int size;
        struct canque_slot_t *slot;
        struct canque_slot_t *slot;
-       if(!slotsnr) slotsnr=MAX_BUF_LENGTH;
-       size=sizeof(struct canque_slot_t)*slotsnr;
-       fifo->entry=kmalloc(size,GFP_KERNEL);
-       if(!fifo->entry) return -1;
+       int slotsnr=fifo->slotsnr;
+       if(!fifo->entry || !slotsnr) return -1;
        slot=fifo->entry;
        fifo->flist=slot;
        while(--slotsnr){
        slot=fifo->entry;
        fifo->flist=slot;
        while(--slotsnr){
@@ -93,18 +90,6 @@ int canque_fifo_init_slots(struct canque_fifo_t *fifo, int slotsnr)
        return 1;
 }
 
        return 1;
 }
 
-/**
- * canque_fifo_done - frees slots allocated for CAN FIFO
- * @fifo: pointer to the FIFO structure
- */
-int canque_fifo_done(struct canque_fifo_t *fifo)
-{
-       if(fifo->entry)
-               kfree(fifo->entry);
-       fifo->entry=NULL;
-       return 1;
-}
-
 /* atomic_dec_and_test(&qedge->edge_used);
  void atomic_inc(&qedge->edge_used);
  list_add_tail(struct list_head *new, struct list_head *head)
 /* atomic_dec_and_test(&qedge->edge_used);
  void atomic_inc(&qedge->edge_used);
  list_add_tail(struct list_head *new, struct list_head *head)
@@ -492,6 +477,7 @@ int canque_flush(struct canque_edge_t *qedge)
 int canqueue_ends_init_gen(struct canque_ends_t *qends)
 {
        int i;
 int canqueue_ends_init_gen(struct canque_ends_t *qends)
 {
        int i;
+       qends->ends_flags=0;
        for(i=CANQUEUE_PRIO_NR;--i>=0;){
                INIT_LIST_HEAD(&qends->active[i]);
        }
        for(i=CANQUEUE_PRIO_NR;--i>=0;){
                INIT_LIST_HEAD(&qends->active[i]);
        }
@@ -650,4 +636,45 @@ int canqueue_ends_kill_outlist(struct canque_ends_t *qends)
 }
 
 
 }
 
 
+/**
+ * canqueue_ends_filt_conjuction - computes conjunction of incoming edges filters filters
+ * @qends: pointer to ends structure
+ * @filt: pointer the filter structure filled by computed filters conjunction
+ *
+ * Return Value: Number of incoming edges
+ */
+int canqueue_ends_filt_conjuction(struct canque_ends_t *qends, struct canfilt_t *filt)
+{
+       struct canque_edge_t *edge;
+       int cnt=0;
+       unsigned long filtid=0;
+       unsigned long filtmask=~0;
+       unsigned long local_only=canque_filtid2internal(0,MSG_LOCAL);
+
+       canque_for_each_inedge(qends, edge){
+               /* skip edges processing only local messages */
+               if(edge->filtid & edge->filtmask & local_only)
+                       continue;
+
+               if(!cnt++)
+                       filtid = edge->filtid;
+               else
+                       filtmask &= ~(filtid ^ edge->filtid);
+       
+               filtmask &= edge->filtmask;
+       }
+       
+       filt->id = filtid & MSG_ID_MASK;
+       filt->mask = filtmask & MSG_ID_MASK;
+       filtid >>= 28;
+       filtmask >>= 28;
+       filt->flags = filtid & MSG_EXT;
+       if(filtmask & (MSG_EXT))
+               filt->flags |= MSG_EXT_MASK;
+       if(filtid & (MSG_RTR<<1))
+               filt->flags |= MSG_RTR<<1;
+       if(filtmask & (MSG_RTR<<1))
+               filt->flags |= MSG_RTR_MASK;
+       return cnt;
+}