Added Files:
 	buffercache.h

git-svn-id: 17d41c460f3ddabe6271dd210d2e0bf85f349cae@282 29311d96-e01e-0410-9327-a35deaab8ce9

error: pathspec 'ceph/client/buffercache.h' did not match any file(s) known to git

--- ceph/client/buffercache.h
+++ ceph/client/buffercache.h
@@ -0,0 +1,133 @@
+#ifndef __BUFFERCACHE_H
+#define __BUFFERCACHE_H
+
+#include "include/buffer.h"
+#include "include/bufferlist.h"
+#include "include/lru.h"
+
+/** map<off_t, bufferptr> buffer_map;
+
+for writes:
+
+void map_or_alloc(size_t len, off_t off, bufferlist &blist);
+- build a bufferlist that includes bufferptr's for existing buffers
+  in the map and (if necessary) newly allocated ones.  caller can then use
+
+  blist.copy_from(int off, int len, char *buf);
+
+  to copy data into the bufferlist.  (copy() copies data _out_, and append appends,
+  but copy_from or copy_into or whatever doesn't exist yet.)
+
+
+  for reads:
+  void map_existing(size_t len, off_t off, map<off_t, bufferlist>& hits, map<off_t, size_t>& holes)
+
+- gives caller map of hits and holes.
+
+
+both of those could be wrapped up in a tidy class, aside from 2 things:
+
+- buffers need to be put in an lru of some sort with last_accessed etc.
+  so we can flush them intelligently
+
+- maybe the buffers should be allocated w/ fixed size?  for writes at least,
+  the new buffers can always be created as 256k (or whatever) and the bufferptrs
+  that reference them (in buffer_map) will point to the relevant substring.
+  the map_or_alloc() bit just needs to be smart then to check the underlying
+  buffer's alloc'd size and adjust those subsets as necessary.
+
+  for reads, we'll be getting buffers of weird sizes coming from osds,
+  so the cache should work with weird sized buffers regardless.
+  (even if we always prefetch large blocks, files tails will come back small.)
+
+
+  so somewhere in there there should be a buffer_head struct or something. maybe it shoudl be
+
+  map<off_t, bufferhead> buffer_map;
+
+  we can reuse the LRU (include/lru.h) thinger to handle lru stuff pretty easily.
+  maybe
+
+  class bufferhead : public LRUObject {
+  bufferptr bptr;
+  time_t    last_written;
+  int       state;  // clean, dirty, writing, reading
+  };
+
+gets weird too if say multiple reads are issued on the same (or overlapping) ranges of bytes..
+only want to submit a single read request.
+
+s
+*/
+
+// bufferhead states
+#define BUFHD_STATE_CLEAN	1
+#define BUFHD_STATE_DIRTY	2
+#define BUFHD_STATE_WRITING	3
+#define BUFHD_STATE_READING	4
+
+class bufferhead : public LRUObject {
+  bufferptr	bptr;
+  time_t	last_written;
+  int		state;
+};
+
+class buffercache {
+ private:
+  map<off_t, bufferhead> buffer_map;
+
+  map<off_t, bufferhead>::iterator overlap(size_t len, off_t off)
+  {
+    // returns iterator to buffer overlapping specified extent or end() if no overlap exists
+    map<off_t, bufferhead>::iterator it = buffer_map.lower_bound(off);
+    if (it == buffer_map.end() || (*it)->first < off + len) {
+      return it;
+    } else if (it == buffer_map.begin()) {
+      return buffer_map.end();
+    } else {
+      --it;
+      if ((*it)->first + (*it)->second.bptr.length() > off) {
+        return it;
+      } else {
+        return buffer_map.end();
+      }
+    }
+  }
+
+ public:
+  /* for writes
+     build a bufferlist that includes bufferptr's for existing buffers
+     in the map and (if necessary) newly allocated ones.  caller can then use
+
+	 blist.copy_from(int off, int len, char *buf);
+
+	 to copy data into the bufferlist. (copy() copies data _out_, and append appends,
+	 but copy_from or copy_into or whatever doesn't exist yet.)
+  */
+  void map_or_alloc(size_t len, off_t off, bufferlist &blist)
+  {
+  }
+
+  /* for reads
+     gives caller maps of hits and holes
+  */
+  void map_existing(size_t len, off_t off, map<off_t, bufferhead>& hits, map<off_t, size_t>& holes)
+  {
+    off_t next_off = off;
+    for (map<off_t, bufferhead>::iterator it = overlap(len, off);
+         it != buffer_map.end() && (*it)->first < off + len;
+         it++) {
+      if ((*it)->first > next_off) {
+        holes[next_off] = (size_t) ((*it)->first - next_off);
+      }
+      hits[(*it)->first] = (*it)->second;
+      next_off = (*it)->first + (*it)->second.bptr.length();
+    }
+    if (next_off < off + len) {
+      holes[next_off] = (size_t) (off + len - next_off);
+    }
+  }
+};
+
+#endif
+


tools: fix lxc-create with global config value II

Signed-off-by: Christian Brauner <48455ab3070520a2d174545c7239d6d0fabd9a83@ubuntu.com>

--- src/lxc/tools/lxc_create.c
+++ src/lxc/tools/lxc_create.c
@@ -267,24 +267,19 @@
 		exit(EXIT_FAILURE);
 	}

-	if (geteuid()) {
-		if (!my_args.lxcpath[0])
-			my_args.lxcpath[0] = lxc_get_global_config_item("lxc.lxcpath");
-
-		if (mkdir_p(my_args.lxcpath[0], 0755))
+
+	if (!my_args.lxcpath[0])
+		my_args.lxcpath[0] = lxc_get_global_config_item("lxc.lxcpath");
+
+	if (mkdir_p(my_args.lxcpath[0], 0755))
+		exit(EXIT_FAILURE);
+
+	if (geteuid())
+		if (access(my_args.lxcpath[0], O_RDONLY) < 0) {
+			fprintf(stderr, "You lack access to %s\n",
+				my_args.lxcpath[0]);
 			exit(EXIT_FAILURE);
-
-		if (access(my_args.lxcpath[0], O_RDONLY) < 0) {
-			fprintf(stderr, "You lack access to %s\n", my_args.lxcpath[0]);
-			exit(EXIT_FAILURE);
-		}
-		if (strcmp(my_args.bdevtype, "dir") && strcmp(my_args.bdevtype, "_unset") &&
-				strcmp(my_args.bdevtype, "btrfs")) {
-			fprintf(stderr, "Unprivileged users cannot create %s containers.\n", my_args.bdevtype);
-			exit(EXIT_FAILURE);
-		}
-	}
-
+		}

 	c = lxc_container_new(my_args.name, my_args.lxcpath[0]);
 	if (!c) {


Coverity: Remove a check for >= 0 because it is always true.  Type is unsigned int.

CID=573
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/256019

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@27682 0039d316-1c4b-4281-b951-d872f2087c98

--- chrome/common/page_transition_types.h
+++ chrome/common/page_transition_types.h
@@ -128,7 +128,7 @@

   static bool ValidType(int32 type) {
     Type t = StripQualifier(static_cast<Type>(type));
-    return (t >= 0 && t <= LAST_CORE);
+    return (t <= LAST_CORE);
   }

   static Type FromInt(int32 type) {


can: janz-ican3: fix support for CAN_RAW_RECV_OWN_MSGS

The Janz VMOD-ICAN3 firmware does not support any sort of TX-done
notification or interrupt. The driver previously used the hardware
loopback to attempt to work around this deficiency, but this caused all
sockets to receive all messages, even if CAN_RAW_RECV_OWN_MSGS is off.

Using the new function ican3_cmp_echo_skb(), we can drop the loopback
messages and return the original skbs. This fixes the issues with
CAN_RAW_RECV_OWN_MSGS.

A private skb queue is used to store the echo skbs. This avoids the need
for any index management.

Due to a lack of TX-error interrupts, bus errors are permanently
enabled, and are used as a TX-error notification. This is used to drop
an echo skb when transmission fails. Bus error packets are not generated
if the user has not enabled bus error reporting.

Signed-off-by: Ira W. Snyder <db42e9324d3f37cb05970bc4fc1606acfcc4d708@ovro.caltech.edu>
Signed-off-by: Marc Kleine-Budde <4a0ea1158d3cc63151119c05b1bff00c0bdbf421@pengutronix.de>

--- drivers/net/can/janz-ican3.c
+++ drivers/net/can/janz-ican3.c
@@ -220,6 +220,9 @@
 	/* old and new style host interface */
 	unsigned int iftype;

+	/* queue for echo packets */
+	struct sk_buff_head echoq;
+
 	/*
 	 * Any function which changes the current DPM page must hold this
 	 * lock while it is performing data accesses. This ensures that the
@@ -925,7 +928,7 @@
 	struct net_device *dev = mod->ndev;
 	struct net_device_stats *stats = &dev->stats;
 	enum can_state state = mod->can.state;
-	u8 status, isrc, rxerr, txerr;
+	u8 isrc, ecc, status, rxerr, txerr;
 	struct can_frame *cf;
 	struct sk_buff *skb;

@@ -941,14 +944,42 @@
 		return -EINVAL;
 	}

+	isrc = msg->data[0];
+	ecc = msg->data[2];
+	status = msg->data[3];
+	rxerr = msg->data[4];
+	txerr = msg->data[5];
+
+	/*
+	 * This hardware lacks any support other than bus error messages to
+	 * determine if packet transmission has failed.
+	 *
+	 * When TX errors happen, one echo skb needs to be dropped from the
+	 * front of the queue.
+	 *
+	 * A small bit of code is duplicated here and below, to avoid error
+	 * skb allocation when it will just be freed immediately.
+	 */
+	if (isrc == CEVTIND_BEI) {
+		int ret;
+		dev_dbg(mod->dev, "bus error interrupt\n");
+
+		/* TX error */
+		if (!(ecc & ECC_DIR)) {
+			kfree_skb(skb_dequeue(&mod->echoq));
+			stats->tx_errors++;
+		} else {
+			stats->rx_errors++;
+		}
+
+		/* bus error reporting is off, return immediately */
+		if (!(mod->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING))
+			return 0;
+	}
+
 	skb = alloc_can_err_skb(dev, &cf);
 	if (skb == NULL)
 		return -ENOMEM;
-
-	isrc = msg->data[0];
-	status = msg->data[3];
-	rxerr = msg->data[4];
-	txerr = msg->data[5];

 	/* data overrun interrupt */
 	if (isrc == CEVTIND_DOI || isrc == CEVTIND_LOST) {
@@ -978,9 +1009,6 @@

 	/* bus error interrupt */
 	if (isrc == CEVTIND_BEI) {
-		u8 ecc = msg->data[2];
-
-		dev_dbg(mod->dev, "bus error interrupt\n");
 		mod->can.can_stats.bus_error++;
 		cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR;

@@ -1000,12 +1028,8 @@
 			break;
 		}

-		if (!(ecc & ECC_DIR)) {
+		if (!(ecc & ECC_DIR))
 			cf->data[2] |= CAN_ERR_PROT_TX;
-			stats->tx_errors++;
-		} else {
-			stats->rx_errors++;
-		}

 		cf->data[6] = txerr;
 		cf->data[7] = rxerr;
@@ -1090,6 +1114,88 @@
 }

 /*
+ * The ican3 needs to store all echo skbs, and therefore cannot
+ * use the generic infrastructure for this.
+ */
+static void ican3_put_echo_skb(struct ican3_dev *mod, struct sk_buff *skb)
+{
+	struct sock *srcsk = skb->sk;
+
+	if (atomic_read(&skb->users) != 1) {
+		struct sk_buff *old_skb = skb;
+
+		skb = skb_clone(old_skb, GFP_ATOMIC);
+		kfree_skb(old_skb);
+		if (!skb)
+			return;
+	} else {
+		skb_orphan(skb);
+	}
+
+	skb->sk = srcsk;
+
+	/* save this skb for tx interrupt echo handling */
+	skb_queue_tail(&mod->echoq, skb);
+}
+
+static unsigned int ican3_get_echo_skb(struct ican3_dev *mod)
+{
+	struct sk_buff *skb = skb_dequeue(&mod->echoq);
+	struct can_frame *cf;
+	u8 dlc;
+
+	/* this should never trigger unless there is a driver bug */
+	if (!skb) {
+		netdev_err(mod->ndev, "BUG: echo skb not occupied\n");
+		return 0;
+	}
+
+	cf = (struct can_frame *)skb->data;
+	dlc = cf->can_dlc;
+
+	/* check flag whether this packet has to be looped back */
+	if (skb->pkt_type != PACKET_LOOPBACK) {
+		kfree_skb(skb);
+		return dlc;
+	}
+
+	skb->protocol = htons(ETH_P_CAN);
+	skb->pkt_type = PACKET_BROADCAST;
+	skb->ip_summed = CHECKSUM_UNNECESSARY;
+	skb->dev = mod->ndev;
+	netif_receive_skb(skb);
+	return dlc;
+}
+
+/*
+ * Compare an skb with an existing echo skb
+ *
+ * This function will be used on devices which have a hardware loopback.
+ * On these devices, this function can be used to compare a received skb
+ * with the saved echo skbs so that the hardware echo skb can be dropped.
+ *
+ * Returns true if the skb's are identical, false otherwise.
+ */
+static bool ican3_echo_skb_matches(struct ican3_dev *mod, struct sk_buff *skb)
+{
+	struct can_frame *cf = (struct can_frame *)skb->data;
+	struct sk_buff *echo_skb = skb_peek(&mod->echoq);
+	struct can_frame *echo_cf;
+
+	if (!echo_skb)
+		return false;
+
+	echo_cf = (struct can_frame *)echo_skb->data;
+	if (cf->can_id != echo_cf->can_id)
+		return false;
+
+	if (cf->can_dlc != echo_cf->can_dlc)
+		return false;
+
+	return memcmp(cf->data, echo_cf->data, cf->can_dlc) == 0;
+}
+
+/*
  * Check that there is room in the TX ring to transmit another skb
  *
  * LOCKING: must hold mod->lock
@@ -1098,6 +1204,10 @@
 {
 	struct ican3_fast_desc __iomem *desc;
 	u8 control;
+
+	/* check that we have echo queue space */
+	if (skb_queue_len(&mod->echoq) >= ICAN3_TX_BUFFERS)
+		return false;

 	/* copy the control bits of the descriptor */
 	ican3_set_page(mod, mod->fasttx_start + (mod->fasttx_num / 16));
@@ -1149,10 +1259,27 @@
 	/* convert the ICAN3 frame into Linux CAN format */
 	ican3_to_can_frame(mod, &desc, cf);

-	/* receive the skb, update statistics */
-	netif_receive_skb(skb);
+	/*
+	 * If this is an ECHO frame received from the hardware loopback
+	 * feature, use the skb saved in the ECHO stack instead. This allows
+	 * the Linux CAN core to support CAN_RAW_RECV_OWN_MSGS correctly.
+	 *
+	 * Since this is a confirmation of a successfully transmitted packet
+	 * sent from this host, update the transmit statistics.
+	 *
+	 * Also, the netdevice queue needs to be allowed to send packets again.
+	 */
+	if (ican3_echo_skb_matches(mod, skb)) {
+		stats->tx_packets++;
+		stats->tx_bytes += ican3_get_echo_skb(mod);
+		kfree_skb(skb);
+		goto err_noalloc;
+	}
+
+	/* update statistics, receive the skb */
 	stats->rx_packets++;
 	stats->rx_bytes += cf->can_dlc;
+	netif_receive_skb(skb);

 err_noalloc:
 	/* toggle the valid bit and return the descriptor to the ring */
@@ -1175,13 +1302,13 @@
 static int ican3_napi(struct napi_struct *napi, int budget)
 {
 	struct ican3_dev *mod = container_of(napi, struct ican3_dev, napi);
-	struct ican3_msg msg;
 	unsigned long flags;
 	int received = 0;
 	int ret;

 	/* process all communication messages */
 	while (true) {
+		struct ican3_msg msg;
 		ret = ican3_recv_msg(mod, &msg);
 		if (ret)
 			break;
@@ -1353,26 +1480,12 @@
 static int ican3_open(struct net_device *ndev)
 {
 	struct ican3_dev *mod = netdev_priv(ndev);
-	u8 quota;
 	int ret;

 	/* open the CAN layer */
 	ret = open_candev(ndev);
 	if (ret) {
 		dev_err(mod->dev, "unable to start CAN layer\n");
-		return ret;
-	}
-
-	/* set the bus error generation state appropriately */
-	if (mod->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING)
-		quota = ICAN3_BUSERR_QUOTA_MAX;
-	else
-		quota = 0;
-
-	ret = ican3_set_buserror(mod, quota);
-	if (ret) {
-		dev_err(mod->dev, "unable to set bus-error\n");
-		close_candev(ndev);
 		return ret;
 	}

@@ -1407,6 +1520,9 @@
 		return ret;
 	}

+	/* drop all outstanding echo skbs */
+	skb_queue_purge(&mod->echoq);
+
 	/* close the CAN layer */
 	close_candev(ndev);
 	return 0;
@@ -1415,7 +1531,6 @@
 static int ican3_xmit(struct sk_buff *skb, struct net_device *ndev)
 {
 	struct ican3_dev *mod = netdev_priv(ndev);
-	struct net_device_stats *stats = &ndev->stats;
 	struct can_frame *cf = (struct can_frame *)skb->data;
 	struct ican3_fast_desc desc;
 	void __iomem *desc_addr;
@@ -1428,8 +1543,7 @@

 	/* check that we can actually transmit */
 	if (!ican3_txok(mod)) {
-		dev_err(mod->dev, "no free descriptors, stopping queue\n");
-		netif_stop_queue(ndev);
+		dev_err(mod->dev, "BUG: no free descriptors\n");
 		spin_unlock_irqrestore(&mod->lock, flags);
 		return NETDEV_TX_BUSY;
 	}
@@ -1442,6 +1556,14 @@

 	/* convert the Linux CAN frame into ICAN3 format */
 	can_frame_to_ican3(mod, cf, &desc);
+
+	/*
+	 * This hardware doesn't have TX-done notifications, so we'll try and
+	 * emulate it the best we can using ECHO skbs. Add the skb to the ECHO
+	 * stack. Upon packet reception, check if the ECHO skb and received
+	 * skb match, and use that to wake the queue.
+	 */
+	ican3_put_echo_skb(mod, skb);

 	/*
 	 * the programming manual says that you must set the IVALID bit, then
@@ -1461,19 +1583,7 @@
 	mod->fasttx_num = (desc.control & DESC_WRAP) ? 0
 						     : (mod->fasttx_num + 1);

-	/* update statistics */
-	stats->tx_packets++;
-	stats->tx_bytes += cf->can_dlc;
-	kfree_skb(skb);
-
-	/*
-	 * This hardware doesn't have TX-done notifications, so we'll try and
-	 * emulate it the best we can using ECHO skbs. Get the next TX
-	 * descriptor, and see if we have room to send. If not, stop the queue.
-	 * It will be woken when the ECHO skb for the current packet is recv'd.
-	 */
-
-	/* copy the control bits of the descriptor */
+	/* if there is no free descriptor space, stop the transmit queue */
 	if (!ican3_txok(mod))
 		netif_stop_queue(ndev);

@@ -1669,6 +1779,7 @@
 	mod->dev = &pdev->dev;
 	mod->num = pdata->modno;
 	netif_napi_add(ndev, &mod->napi, ican3_napi, ICAN3_RX_BUFFERS);
+	skb_queue_head_init(&mod->echoq);
 	spin_lock_init(&mod->lock);
 	init_completion(&mod->termination_comp);
 	init_completion(&mod->buserror_comp);


New tests

New tests

--- tests/tests.c
+++ tests/tests.c
@@ -8,6 +8,7 @@
 #include <math.h>

 #include "../src/vect-ops/vect-ops.h"
+#include "../src/voxtrees/voxtrees.h"

 #define PROC_SUIT_ERROR do {res = CU_get_error (); \
         printf ("Failed to add a suite\n");        \
@@ -20,6 +21,10 @@
     while (0)

 #define PREC 0.00001
+#define NSET 2000000
+
+vox_dot *working_set;
+struct vox_node *working_tree;

 int vect_eq (vox_dot v1, vox_dot v2)
 {
@@ -141,6 +146,64 @@
     CU_ASSERT (fabsf (dot_product (vect, vect) - dot_product (res, res)) < PREC);
 }

+void prepare_rnd_set_and_tree (struct vox_node **node_ptr, vox_dot **set_ptr)
+{
+    int i;
+    vox_dot *set = malloc (sizeof (vox_dot) * NSET);
+    for (i=0; i<NSET; i++)
+    {
+        set[i][0] = 1.0*rand();
+        set[i][1] = 1.0*rand();
+        set[i][2] = 1.0*rand();
+    }
+
+    *node_ptr = vox_make_tree (set, NSET);
+    *set_ptr = set;
+}
+
+void check_tree (struct vox_node *tree)
+{
+    vox_dot snd_corner;
+    vox_uint i;
+
+    if (VOX_LEAFP (tree))
+    {
+        vox_leaf_data leaf = tree->data.leaf;
+
+        // Check if empty leaf is really empty
+        if (leaf.dots_num == 0) CU_ASSERT (!(VOX_FULLP (tree)));
+        // Check that all voxels are covered by bounding box
+        for (i=0; i<leaf.dots_num; i++)
+        {
+            sum_vector (leaf.dots[i], vox_voxel, snd_corner);
+            CU_ASSERT (dot_betweenp (tree->bb_min, tree->bb_max, leaf.dots[i]));
+            CU_ASSERT (dot_betweenp (tree->bb_min, tree->bb_max, snd_corner));
+        }
+    }
+    else
+    {
+        vox_inner_data inner = tree->data.inner;
+        for (i=0; i<VOX_NS; i++)
+        {
+            struct vox_node *child = inner.children[i];
+            if (VOX_FULLP (child))
+            {
+                // Check if child's bounding box is inside parent's
+                CU_ASSERT (dot_betweenp (tree->bb_min, tree->bb_max, child->bb_min));
+                CU_ASSERT (dot_betweenp (tree->bb_min, tree->bb_max, child->bb_max));
+
+                // Check subspace
+                CU_ASSERT (get_subspace_idx (inner.center, child->bb_min) == i);
+                CU_ASSERT (get_subspace_idx (inner.center, child->bb_max) == i);
+            }
+            // Test a child recursively
+            check_tree (child);
+        }
+    }
+}
+
+void test_tree_cons () {check_tree (working_tree);}
+
 int main ()
 {
     CU_pTest test;
@@ -152,6 +215,7 @@
         goto exit_;
     }

+    // Working with vectors
     CU_pSuite vect_suite = CU_add_suite ("vect-ops", NULL, NULL);
     if (vect_suite == NULL) PROC_SUIT_ERROR;

@@ -170,6 +234,16 @@
     test = CU_add_test (vect_suite, "Rotation saves norm", rot_saves_norm);
     if (test == NULL) PROC_TEST_ERROR;

+    // Tree construction and searching
+    CU_pSuite vox_suite = CU_add_suite ("voxtrees", NULL, NULL);
+    if (vox_suite == NULL) PROC_SUIT_ERROR;
+
+    test = CU_add_test (vox_suite, "Tree construction", test_tree_cons);
+    if (test == NULL) PROC_TEST_ERROR;
+
+    printf ("Creating working set and working tree\n");
+    prepare_rnd_set_and_tree (&working_tree, &working_set);
+
     CU_basic_set_mode(CU_BRM_VERBOSE);
     CU_basic_run_tests();


BLE: provide better default connection parameters.

--- features/FEATURE_BLE/ble/gap/ConnectionParameters.h
+++ features/FEATURE_BLE/ble/gap/ConnectionParameters.h
@@ -145,10 +145,10 @@
         phy_t phy = phy_t::LE_1M,
         scan_interval_t scanInterval = scan_interval_t::min(),
         scan_window_t scanWindow = scan_window_t::min(),
-        conn_interval_t minConnectionInterval = conn_interval_t::min(),
-        conn_interval_t maxConnectionInterval = conn_interval_t::max(),
+        conn_interval_t minConnectionInterval = conn_interval_t(50),
+        conn_interval_t maxConnectionInterval = conn_interval_t(100),
         slave_latency_t slaveLatency = slave_latency_t::min(),
-        supervision_timeout_t connectionSupervisionTimeout = supervision_timeout_t::max(),
+        supervision_timeout_t connectionSupervisionTimeout = supervision_timeout_t(100),
         conn_event_length_t minEventLength = conn_event_length_t::min(),
         conn_event_length_t maxEventLength = conn_event_length_t::max()
     );


- iwkv

- iwkv

--- src/kv/iwkv.c
+++ src/kv/iwkv.c
@@ -104,22 +104,15 @@
 } KVBLK;

 typedef enum {
-  SBH_FULL_LKEY = 1,          /**< The lowest `SBLK` key is fully contained in `SBLK`. Persistent flag. */
+  SBLK_FULL_LKEY = 1,         /**< The lowest `SBLK` key is fully contained in `SBLK`. Persistent flag. */
   SBH_DB = 1 << 1,            /**< This block is the database block. */
   SBH_PINNED = 1 << 2,        /**< `SBH` pinned and should not be released. */
   SBH_WLOCKED = 1 << 3,       /**< `SBH` write locked */
   SBH_NO_LOCK = 1 << 4,       /**< Do not use locks when accessing `SBH`(used in debug print routines) */
+  SBLK_DURTY = 1 << 5
 } sbh_flags_t;

 #define SBH_PERSISTENT_FLAGS (SBH_FULL_LKEY)
-
-/* Common header for IWDB and SBLK */
-typedef struct SBH {
-  IWDB db;                    /**< Database ref */
-  off_t addr;                 /**< Block address */
-  sbh_flags_t flags;          /**< Flags */
-  uint8_t lvl;                /**< Skip list node level */
-} SBH;

 /* Address lock node */
 typedef struct ALN {
@@ -159,6 +152,8 @@
   // !SBH
   KVBLK *kvblk;               /**< Associated KVBLK */
   blkn_t kvblkn;              /**< Associated KVBLK block number */
+  int8_t pnum;
+  int8_t pi[KVBLK_IDXNUM];
 } SBLK;

@@ -186,22 +181,31 @@
   IWDB db;
   const IWKV_val *key;        /**< Search key */
   IWKV_val *val;              /**< Update value */
-  SBH *lower;                 /**< Next to upper bound block */
-  SBH *upper;                 /**< Upper bound block */
-  SBH *nb;                    /**< New block */
-  SBH *plower[SLEVELS];       /**< Pinned lower nodes per level */
-  SBH *pupper[SLEVELS];       /**< Pinned upper nodes per level */
+  SBLK *lower;                 /**< Next to upper bound block */
+  SBLK *upper;                 /**< Upper bound block */
+  SBLK *nb;                    /**< New block */
+  SBLK *plower[SLEVELS];       /**< Pinned lower nodes per level */
+  SBLK *pupper[SLEVELS];       /**< Pinned upper nodes per level */
+  uint8_t aapos;             /**< Position of next free element in allocation area */
   SBLK saa[AANUM];            /**< `SBLK` allocation area */
   KVBLK kaa[AANUM];           /**< `KVBLK` allocation area */
-  int8_t aapos;               /**< Position of next free element in allocation area */
   int8_t lvl;                 /**< Current level */
   int8_t nlvl;                /**< Level of new inserted `SBLK` node. -1 if no new node inserted */
   iwlctx_op_t op;             /**< Context operation flags */
   iwkv_opflags opflg;         /**< Operation flags */
 } IWLCTX;

+#define AAPOS_INC(aapos_)        \
+  do {                           \
+    if ((aapos_) < AANUM - 1) {  \
+      (aapos_) = (aapos_) + 1;   \
+    } else {                     \
+      (aapos_) = 0;              \
+    }                            \
+  } while(0)
+
 void iwkvd_kvblk(FILE *f, KVBLK *kb);
-void iwkvd_sblk(FILE *f, SBH *sb, int flags);
+void iwkvd_sblk(FILE *f, SBLK *sb, int flags);
 void iwkvd_db(FILE *f, IWDB db, int flags);

 #define ENSURE_OPEN(iwkv_) \
@@ -248,7 +252,7 @@

 #define _mm_set_u1(mm_, off_, v_) (*((mm_) + (off_)) = (v_))

-IW_INLINE uint32_t _mm_u4(uint8_t *mm, off_t off) {
+IW_INLINE uint32_t _mm_u4(const uint8_t *mm, off_t off) {
   uint32_t lv;
   memcpy(&lv, mm + off, sizeof(lv));
   return IW_ITOHL(lv);
@@ -259,7 +263,7 @@
   memcpy(mm + off, &lv, sizeof(lv));
 }

-IW_INLINE uint64_t _mm_u8(uint8_t *mm, off_t off) {
+IW_INLINE uint64_t _mm_u8(const uint8_t *mm, off_t off) {
   uint64_t llv;
   memcpy(&llv, mm + off, sizeof(llv));
   return IW_ITOHLL(llv);
@@ -270,55 +274,10 @@
   memcpy(mm + off, &llv, sizeof(llv));
 }

-//-------------------------- SBH
-
-IW_INLINE uint8_t _sbh_u1(SBH *sbh, off_t off, uint8_t *mm) {
-  return _mm_u1(mm + sbh->addr, off);
-}
-
-IW_INLINE void _sbh_set_u1(SBH *sbh, off_t off, uint8_t *mm, uint8_t v) {
-  _mm_set_u1(mm + sbh->addr, off, v);
-}
-
-IW_INLINE uint32_t _sbh_u4(SBH *sbh, off_t off, uint8_t *mm) {
-  return _mm_u4(mm + sbh->addr, off);
-}
-
-IW_INLINE void _sbh_set_u4(SBH *sbh, off_t off, uint8_t *mm, uint32_t lv) {
-  _mm_set_u4(mm + sbh->addr, off, lv);
-}
-
-IW_INLINE uint64_t _sbh_u8(SBH *sbh, off_t off, uint8_t *mm) {
-  return _mm_u8(mm + sbh->addr, off);
-}
-
-IW_INLINE void _sbh_set_u8(SBH *sbh, off_t off, uint8_t *mm, uint64_t llv) {
-  _mm_set_u8(mm + sbh->addr, off, llv);
-}
-
-IW_INLINE blkn_t _sbh_n(SBH *sbh, uint8_t *mm, uint32_t n) {
-  assert(sbh && mm && n < SLEVELS);
-  return _sbh_u4(sbh, ((sbh->flags & SBH_DB) ? DOFF_N0_U4 : SOFF_N0_U4) + n * sizeof(uint32_t), mm);
-}
-
-IW_INLINE void _sbh_set_n(SBH *sbh, uint8_t *mm, uint32_t n, blkn_t val) {
-  assert(sbh && mm && n < SLEVELS);
-  _sbh_set_u4(sbh, ((sbh->flags & SBH_DB) ? DOFF_N0_U4 : SOFF_N0_U4) + n * sizeof(uint32_t), mm, val);
-}
-
-IW_INLINE blkn_t _sbh_p0(SBH *sbh, uint8_t *mm, blkn_t val) {
-  assert(sbh && mm);
-  return _sbh_u4(sbh, ((sbh->flags & SBH_DB) ? DOFF_P0_U4 : SOFF_P0_U4), mm);
-}
-
-IW_INLINE void _sbh_set_p0(SBH *sbh, uint8_t *mm, blkn_t val) {
-  assert(sbh && mm);
-  _sbh_set_u4(sbh, ((sbh->flags & SBH_DB) ? DOFF_P0_U4 : SOFF_P0_U4), mm, val);
-}
-
 //--------------------------  ADDRESS LOCKING

-IW_INLINE iwrc _aln_release(IWDB db, blkn_t blkn) {
+IW_INLINE iwrc _aln_release(IWDB db,
+                            blkn_t blkn) {
   int rci = pthread_mutex_lock(&db->mtx_ctl);
   if (rci) return iwrc_set_errno(IW_ERROR_THREADING_ERRNO, rci);
   khiter_t k = kh_get(ALN, db->aln, blkn);
@@ -335,7 +294,8 @@
   return 0;
 }

-IW_INLINE iwrc _aln_acquire_read(IWDB db, blkn_t blkn) {
+IW_INLINE iwrc _aln_acquire_read(IWDB db,
+                                 blkn_t blkn) {
   ALN *aln;
   int rci;
   iwrc rc = 0;
@@ -374,7 +334,8 @@
   return rc;
 }

-IW_INLINE iwrc _aln_acquire_write_upgrade(IWDB db, blkn_t blkn) {
+IW_INLINE iwrc _aln_acquire_write_upgrade(IWDB db,
+                                          blkn_t blkn) {
   ALN *aln;
   int rci;
   iwrc rc = 0;
@@ -426,7 +387,8 @@
   return rc;
 }

-IW_INLINE void _kv_dispose(IWKV_val *key, IWKV_val *val) {
+IW_INLINE void _kv_dispose(IWKV_val *key,
+                           IWKV_val *val) {
   if (key) {
     if (key->data) {
       free(key->data);
@@ -445,7 +407,10 @@

 //--------------------------  DB

-static iwrc _db_at(IWKV iwkv, IWDB *dbp, off_t addr, uint8_t *mm) {
+static iwrc _db_at(IWKV iwkv,
+                   IWDB *dbp,
+                   off_t addr,
+                   uint8_t *mm) {
   iwrc rc = 0;
   uint8_t *rp;
   uint32_t lv;
@@ -570,7 +535,10 @@
   return rc;
 }

-static iwrc _db_create_lw(IWKV iwkv, dbid_t dbid, iwdb_flags_t dbflg, IWDB *odb) {
+static iwrc _db_create_lw(IWKV iwkv,
+                          dbid_t dbid,
+                          iwdb_flags_t dbflg,
+                          IWDB *odb) {
   iwrc rc;
   int rci;
   uint8_t *mm;
@@ -627,14 +595,16 @@

 //--------------------------  KVBLK

-static iwrc _kvblk_create(IWLCTX *lx, int8_t kvbpow, KVBLK **oblk) {
+static iwrc _kvblk_create(IWLCTX *lx,
+                          int8_t kvbpow,
+                          KVBLK **oblk) {
   KVBLK *kblk;
   off_t baddr = 0, blen;
   IWFS_FSM *fsm = &lx->db->iwkv->fsm;
   if (kvbpow < KVBLK_INISZPOW) {
     kvbpow = KVBLK_INISZPOW;
   }
-  assert(lx->aapos < SLEVELS);
+  assert(lx->aapos < AANUM);
   kblk = &lx->kaa[lx->aapos];
   memset(lx->kaa, 0, sizeof(lx->kaa[0]));
   iwrc rc = fsm->allocate(fsm, (1ULL << kvbpow), &baddr, &blen,
@@ -697,7 +667,10 @@
   }
 }

-static iwrc _kvblk_getkey(KVBLK *kb, uint8_t *mm, uint8_t idx, IWKV_val *key) {
+static iwrc _kvblk_getkey(KVBLK *kb,
+                          uint8_t *mm,
+                          uint8_t idx,
+                          IWKV_val *key) {
   assert(mm && idx < KVBLK_IDXNUM);
   int32_t klen;
   int step;
@@ -724,7 +697,10 @@
   return 0;
 }

-static iwrc _kvblk_getvalue(KVBLK *kb, uint8_t *mm, uint8_t idx, IWKV_val *val) {
+static iwrc _kvblk_getvalue(KVBLK *kb,
+                            uint8_t *mm,
+                            uint8_t idx,
+                            IWKV_val *val) {
   assert(mm && idx < KVBLK_IDXNUM);
   int32_t klen;
   int step;
@@ -759,7 +735,11 @@
   return 0;
 }

-static iwrc _kvblk_getkv(uint8_t *mm, KVBLK *kb, uint8_t idx, IWKV_val *key, IWKV_val *val) {
+static iwrc _kvblk_getkv(uint8_t *mm,
+                         KVBLK *kb,
+                         uint8_t idx,
+                         IWKV_val *key,
+                         IWKV_val *val) {
   assert(mm && idx < KVBLK_IDXNUM);
   int32_t klen;
   int step;
@@ -804,7 +784,10 @@
   return 0;
 }

-static iwrc _kvblk_at_mm(IWLCTX *lx, off_t addr, uint8_t *mm, KVBLK **blkp) {
+static iwrc _kvblk_at_mm(IWLCTX *lx,
+                         off_t addr,
+                         uint8_t *mm,
+                         KVBLK **blkp) {
   uint8_t *rp, *sp;
   uint16_t sv;
   int step;
@@ -852,7 +835,9 @@
   return rc;
 }

-IW_INLINE iwrc _kvblk_at(IWLCTX *lx, SBLK *sblk, KVBLK **blkp) {
+IW_INLINE iwrc _kvblk_at(IWLCTX *lx,
+                         SBLK *sblk,
+                         KVBLK **blkp) {
   if (sblk->kvblk) {
     *blkp = sblk->kvblk;
     return 0;
@@ -868,7 +853,8 @@
   return rc;
 }

-static void _kvblk_sync(KVBLK *kb, uint8_t *mm) {
+static void _kvblk_sync_mm(KVBLK *kb,
+                           uint8_t *mm) {
   if (!(kb->flags & KVBLK_DURTY)) {
     return;
   }
@@ -902,13 +888,15 @@
   return coff;
 }

-static int _kvblk_sort_kv(const void *v1, const void *v2) {
+static int _kvblk_sort_kv(const void *v1,
+                          const void *v2) {
   uint32_t o1 = ((KVP *) v1)->off > 0 ? ((KVP *) v1)->off : -1UL;
   uint32_t o2 = ((KVP *) v2)->off > 0 ? ((KVP *) v2)->off : -1UL;
   return o1 > o2 ? 1 : o1 < o2 ? -1 : 0;
 }

-static void _kvblk_compact(KVBLK *kb, uint8_t *mm) {
+static void _kvblk_compact(KVBLK *kb,
+                           uint8_t *mm) {
   uint8_t i;
   off_t coff = _kvblk_compacted_offset(kb);
   if (coff == kb->maxoff) { // already compacted
@@ -944,7 +932,7 @@
     kb->zidx = -1;
   }
   kb->flags |= KVBLK_DURTY;
-  _kvblk_sync(kb, mm);
+  _kvblk_sync_mm(kb, mm);
 }

 IW_INLINE uint64_t _kvblk_datasize(KVBLK *kb) {
@@ -965,7 +953,9 @@
   return off;
 }

-iwrc _kvblk_rmkv(KVBLK *kb, uint8_t idx, kvblk_rmkv_opts_t opts) {
+iwrc _kvblk_rmkv(KVBLK *kb,
+                 uint8_t idx,
+                 kvblk_rmkv_opts_t opts) {
   uint64_t sz;
   iwrc rc = 0;
   uint8_t *mm = 0;
@@ -1016,7 +1006,7 @@
       rc = fsm->acquire_mmap(fsm, 0, &mm, 0);
       RCGO(rc, finish);
     }
-    _kvblk_sync(kb, mm);
+    _kvblk_sync_mm(kb, mm);
   }
 finish:
   if (mm) {
@@ -1025,7 +1015,10 @@
   return rc;
 }

-static iwrc _kvblk_addkv(KVBLK *kb, const IWKV_val *key, const IWKV_val *val, int8_t *oidx) {
+static iwrc _kvblk_addkv(KVBLK *kb,
+                         const IWKV_val *key,
+                         const IWKV_val *val,
+                         int8_t *oidx) {
   iwrc rc = 0;
   off_t msz;    // max available free space
   off_t rsz;    // required size to add new key/value pair
@@ -1107,7 +1100,10 @@
   return rc;
 }

-static iwrc _kvblk_updatev(KVBLK *kb, int8_t *idxp, const IWKV_val *key, const IWKV_val *val) {
+static iwrc _kvblk_updatev(KVBLK *kb,
+                           int8_t *idxp,
+                           const IWKV_val *key,
+                           const IWKV_val *val) {
   assert(*idxp < KVBLK_IDXNUM);
   int32_t klen, i;
   size_t sz;
@@ -1166,33 +1162,28 @@

 //--------------------------  SBLK

-IW_INLINE void _sblk_release(IWDB db, SBLK **sblkp) {
+IW_INLINE void _sblk_release(IWLCTX *lx, SBLK **sblkp) {
   assert(sblkp && *sblkp);
   if (!((*sblkp)->flags & SBH_NO_LOCK)) {
-    _aln_release(db, ADDR2BLK((*sblkp)->addr));
+    _aln_release(lx->db, ADDR2BLK((*sblkp)->addr));
   }
   (*sblkp)->kvblk = 0;
   *sblkp = 0;
 }

-IW_INLINE iwrc _sblk_destroy(IWDB db, SBLK **sblkp) {
+IW_INLINE iwrc _sblk_destroy(IWLCTX *lx,
+                             SBLK **sblkp) {
   assert(sblkp && *sblkp && (*sblkp)->kvblk && (*sblkp)->addr);
   iwrc rc;
   SBLK *sblk = *sblkp;
-  IWFS_FSM *fsm = &sblk->kvblk->db->iwkv->fsm;
-  off_t kvb_addr = sblk->kvblk->addr, sblk_addr = sblk->addr;
+  IWFS_FSM *fsm = &lx->db->iwkv->fsm;
+  assert(sblk->kvblk);
+  off_t kvb_addr = BLK2ADDR(sblk->kvblkn), sblk_addr = sblk->addr;
   uint8_t kvb_szpow = sblk->kvblk->szpow;
-  _sblk_release(db, sblkp);
+  _sblk_release(lx, sblkp);
   rc = fsm->deallocate(fsm, sblk_addr, 1 << SBLK_SZPOW);
   IWRC(fsm->deallocate(fsm, kvb_addr, 1ULL << kvb_szpow), rc);
   return rc;
-}
-
-IW_INLINE void _sblk_sync_mm(SBLK *sblk, uint8_t *mm) {
-  assert(sblk && sblk->addr);
-  if (sblk->kvblk && (sblk->kvblk->flags & KVBLK_DURTY)) {
-    _kvblk_sync(sblk->kvblk, mm);
-  }
 }

 static uint8_t _sblk_genlevel() {
@@ -1209,13 +1200,15 @@
   return IW_UNLIKELY(lvl >= SLEVELS) ? SLEVELS - 1 : lvl;
 }

-static iwrc _sblk_create(IWLCTX *lx, int8_t nlevel, int8_t kvbpow, SBLK **oblk) {
+static iwrc _sblk_create(IWLCTX *lx,
+                         int8_t nlevel,
+                         int8_t kvbpow,
+                         SBLK **oblk) {
   iwrc rc;
   SBLK *sblk;
   KVBLK *kvblk;
   off_t baddr = 0, blen;
   IWFS_FSM *fsm = &lx->db->iwkv->fsm;
-  int aanum = lx->aapos % AANUM;
   *oblk = 0;
   rc = _kvblk_create(lx, kvbpow, &kvblk);
   RCRET(rc);
@@ -1225,99 +1218,280 @@
     IWRC(_kvblk_destroy(&kvblk), rc);
     return rc;
   }
-  sblk = &lx->saa[aanum];
+  sblk = &lx->saa[lx->aapos];
   memset(sblk, 0, sizeof(*sblk));
   sblk->db = lx->db;
   sblk->addr = baddr;
   sblk->lvl = nlevel;
   sblk->kvblk = kvblk;
   sblk->kvblkn = ADDR2BLK(kvblk->addr);
+  sblk->flags |= SBLK_DURTY;
   rc = _aln_acquire_read(lx->db, sblk->addr);
   if (!rc) {
     *oblk = sblk;
-    ++lx->aapos;
-  }
-  return rc;
-}
-
-
-
-//typedef struct SBLK {
-//  // SBH
-//  IWDB db;                    /**< Database ref */
-//  off_t addr;                 /**< Block address */
-//  sbh_flags_t flags;          /**< Flags */
-//  uint8_t lvl;                /**< Skip list node level */
-//  // !SBH
-//  KVBLK *kvblk;               /**< Associated KVBLK */
-//  blkn_t kvblkn;              /**< Associated KVBLK block number */
-//} SBLK;
-
-
-//static iwrc _sblk_at(IWDB db, off_t addr, sbh_flags_t flags, SBLK **sblkp) {
-//  iwrc rc;
-//  blkn_t kblkn;
-//  uint32_t lv;
-//  uint8_t *mm, *rp;
-//#ifndef NDEBUG
-//  uint8_t *sp;
-//#endif
-//  IWFS_FSM *fsm = &db->iwkv->fsm;
-//  SBLK *sblk = calloc(1, sizeof(*sblk));
-//  if (!sblk) {
-//    return iwrc_set_errno(IW_ERROR_ALLOC, errno);
-//  }
-//  sblk->db = db;
-//  sblk->addr = addr;
-//  if (!(flags & SBH_NO_LOCK)) {
-//    rc = _aln_acquire_read(db, ADDR2BLK(sblk->addr));
-//    RCRET(rc);
-//  }
-//  rc = fsm->acquire_mmap(fsm, 0, &mm, 0);
-//  RCGO(rc, finish);
-//  rp = mm + addr;
-//#ifndef NDEBUG
-//  sp = rp;
-//#endif
-//  // SBLK: [u1:flags,kblk:u4,lvl:u1,p0:u4,n0-n29:u4,lkl:u1,lk:u61,pnum:u1,[pi1:u1,...pi63]]:u256
-//  memcpy(&sblk->flags, rp, 1);
-//  rp += 1;
-//
-//  sblk->flags |= flags;
-//
-//  IW_READLV(rp, lv, kblkn);
-//  assert(kblkn);
-//  memcpy(&sblk->lvl, rp, 1);
-//  rp += 1;
-//  rc = _kvblk_at2(db, BLK2ADDR(kblkn), mm, &sblk->kvblk);
-//  RCGO(rc, finish);
-//  rp += sizeof(blkn_t); // p0
-//  rp += sizeof(blkn_t) * SLEVELS; // n
-//  memcpy(&sblk->lkl, rp, 1);
-//  rp += 1;
-//  if (sblk->lkl) {
-//    if (sblk->lkl > SBLK_LKLEN) {
-//      rc = IWKV_ERROR_CORRUPTED;
-//      goto finish;
-//    }
-//    memcpy(sblk->lk, rp, sblk->lkl);
-//  }
-//  rp += SBLK_LKLEN;
-//  memcpy(&sblk->pnum, rp, 1);
-//  rp += 1;
-//  memcpy(sblk->pi, rp, KVBLK_IDXNUM);
-//  rp += KVBLK_IDXNUM;
-//  assert(rp - sp == (1 << SBLK_SZPOW));
-//  *sblkp = sblk;
-//finish:
-//  fsm->release_mmap(fsm);
-//  if (rc) {
-//    *sblkp = 0;
-//    _sblk_release(&sblk);
-//  }
-//  return rc;
-//}
-
+    AAPOS_INC(lx->aapos);
+  }
+  return rc;
+}
+
+static iwrc _sblk_at_mm(IWLCTX *lx, off_t addr, sbh_flags_t flags, uint8_t *mm, SBLK **sblkp) {
+  iwrc rc = 0;
+  uint8_t *rp = mm + addr;
+  SBLK *sblk = &lx->saa[lx->aapos];
+  memset(sblk, 0, sizeof(*sblk));
+  if (IW_UNLIKELY(addr == lx->db->addr)) {
+    sblk->addr = addr;
+    sblk->flags = SBH_DB | flags;
+    sblk->db = lx->db;
+    sblk->lvl = lx->db->lvl;
+  } else {
+    sblk->db = lx->db;
+    sblk->addr = addr;
+    if (!(flags & SBH_NO_LOCK)) {
+      rc = _aln_acquire_read(lx->db, ADDR2BLK(sblk->addr));
+      RCRET(rc);
+    }
+    // [u1:flags,lkl:u1,lk:u61,lvl:u1,p0:u4,n0-n29:u4,pnum:u1,kblk:u4,[pi0:u1,...pi62]]:u256
+    memcpy(&sblk->flags, rp + SOFF_FLAGS_U1, 1);
+    sblk->flags |= flags;
+    memcpy(&sblk->lvl, rp + SOFF_LVL_U1, 1);
+    memcpy(&sblk->pnum, rp + SOFF_PNUM_U1, 1);
+    memcpy(&sblk->kvblkn, rp + SOFF_KBLK_U4, 4);
+    memcpy(&sblk->pi, rp + SOFF_PI0_U1, KVBLK_IDXNUM);
+    sblk->kvblkn = IW_ITOHL(sblk->kvblkn);
+  }
+  AAPOS_INC(lx->aapos);
+  return 0;
+}
+
+IW_INLINE void _sblk_sync_mm(SBLK *sblk, uint8_t *mm) {
+  assert(sblk && sblk->addr);
+  if (sblk->kvblk && (sblk->kvblk->flags & KVBLK_DURTY)) {
+    _kvblk_sync_mm(sblk->kvblk, mm);
+  }
+  if (sblk->flags & SBLK_DURTY) {
+    uint8_t *sp = mm + sblk->addr;
+    memcpy(sp, &sblk->flags, 1);
+    memcpy(sp + SOFF_LVL_U1, &sblk->lvl, 1);
+    _mm_set_u4(sp, SOFF_KBLK_U4, sblk->kvblkn);
+    memcpy(sp + SOFF_PI0_U1, sblk->pi, KVBLK_IDXNUM);
+    sblk->flags &= ~SBLK_DURTY;
+  }
+}
+
+static int _sblk_find_pi(SBLK *sblk, const IWKV_val *key, const uint8_t *mm, bool *found) {
+  uint8_t *k;
+  uint32_t kl;
+  int idx = 0,
+      lb = 0,
+      ub = sblk->pnum - 1;
+  *found = false;
+  if (sblk->pnum < 1) {
+    return 0;
+  }
+  while (1) {
+    int cr;
+    idx = (ub + lb) / 2;
+    _kvblk_peek_key(sblk->kvblk, sblk->pi[idx], mm, &k, &kl);
+    assert(kl > 0);
+    IW_CMP(cr, k, kl, key->data, key->size);
+    if (!cr) {
+      *found = true;
+      break;
+    } else if (cr < 0) {
+      lb = idx + 1;
+      if (lb > ub) {
+        idx = lb;
+        break;
+      }
+    } else {
+      ub = idx - 1;
+      if (lb > ub) {
+        break;
+      }
+    }
+  }
+  return idx;
+}
+
+static int _sblk_insert_pi(SBLK *sblk, int8_t nidx, const IWKV_val *key, const uint8_t *mm) {
+  uint8_t *k;
+  uint32_t kl;
+  int idx = 0,
+      lb = 0,
+      ub = sblk->pnum - 1,
+      nels = sblk->pnum;
+  if (nels < 1) {
+    sblk->pi[0] = nidx;
+    sblk->pnum++;
+    return 0;
+  }
+  while (1) {
+    int cr;
+    idx = (ub + lb) / 2;
+    _kvblk_peek_key(sblk->kvblk, sblk->pi[idx], mm, &k, &kl);
+    assert(kl > 0);
+    IW_CMP(cr, k, kl, key->data, key->size);
+    if (!cr) {
+      break;
+    } else if (cr < 0) {
+      lb = idx + 1;
+      if (lb > ub) {
+        idx = lb;
+        sblk->pnum++;
+        break;
+      }
+    } else {
+      ub = idx - 1;
+      if (lb > ub) {
+        sblk->pnum++;
+        break;
+      }
+    }
+  }
+  if (nels - idx > 0) {
+    memmove(sblk->pi + idx + 1, sblk->pi + idx, nels - idx);
+  }
+  sblk->pi[idx] = nidx;
+  return idx;
+}
+
+IW_INLINE iwrc _sblk_addkv2(IWLCTX *lx,
+                            SBLK *sblk,
+                            int8_t idx,
+                            const IWKV_val *key,
+                            const IWKV_val *val) {
+  assert(key && key->size && key->data && val && idx >= 0);
+  uint8_t *mm;
+  int8_t kvidx;
+  KVBLK *kvblk = sblk->kvblk;
+  IWFS_FSM *fsm = &sblk->db->iwkv->fsm;
+  assert(kvblk);
+  if (sblk->pnum >= KVBLK_IDXNUM) {
+    return _IWKV_ERROR_KVBLOCK_FULL;
+  }
+  iwrc rc = _kvblk_addkv(kvblk, key, val, &kvidx);
+  RCRET(rc);
+  if (sblk->pnum - idx > 0) {
+    memmove(sblk->pi + idx + 1, sblk->pi + idx, sblk->pnum - idx);
+  }
+  if (idx == 0) {
+    rc = fsm->acquire_mmap(fsm, 0, &mm, 0);
+    RCRET(rc);
+    uint8_t lkl = MIN(SBLK_LKLEN, key->size);
+    _mm_set_u1(mm, sblk->addr + SOFF_LKL_U1, lkl);
+    memcpy(mm + sblk->addr + SOFF_LK_U61, key->data, lkl);
+    if (key->size <= SBLK_LKLEN) {
+      sblk->flags |= SBLK_FULL_LKEY;
+    } else {
+      sblk->flags &= ~SBLK_FULL_LKEY;
+    }
+    fsm->release_mmap(fsm);
+  }
+  sblk->pi[idx] = kvidx;
+  sblk->pnum++;
+  sblk->flags |= SBLK_DURTY;
+  return 0;
+}
+
+IW_INLINE iwrc _sblk_addkv(SBLK *sblk, const IWKV_val *key, const IWKV_val *val) {
+  assert(key && key->size && key->data && val);
+  iwrc rc;
+  int8_t kvidx;
+  uint8_t *mm;
+  KVBLK *kvblk = sblk->kvblk;
+  assert(kvblk);
+  IWFS_FSM *fsm = &kvblk->db->iwkv->fsm;
+  if (sblk->pnum >= KVBLK_IDXNUM) {
+    return _IWKV_ERROR_KVBLOCK_FULL;
+  }
+  rc = _kvblk_addkv(kvblk, key, val, &kvidx);
+  RCRET(rc);
+  rc = fsm->acquire_mmap(fsm, 0, &mm, 0);
+  RCRET(rc);
+  if (_sblk_insert_pi(sblk, kvidx, key, mm) == 0) { // the lowest key inserted
+    uint8_t lkl = MIN(SBLK_LKLEN, key->size);
+    _mm_set_u1(mm, sblk->addr + SOFF_LKL_U1, lkl);
+    memcpy(mm + sblk->addr + SOFF_LK_U61, key->data, lkl);
+    if (key->size <= SBLK_LKLEN) {
+      sblk->flags |= SBLK_FULL_LKEY;
+    } else {
+      sblk->flags &= ~SBLK_FULL_LKEY;
+    }
+  }
+  fsm->release_mmap(fsm);
+  sblk->flags |= SBLK_DURTY;
+  return 0;
+}
+
+IW_INLINE iwrc _sblk_updatekv(SBLK *sblk, int8_t idx, const IWKV_val *key, const IWKV_val *val) {
+  assert(idx >= 0 && idx < sblk->pnum);
+  iwrc rc;
+  KVBLK *kvblk = sblk->kvblk;
+  int8_t kvidx = sblk->pi[idx];
+  rc = _kvblk_updatev(kvblk, &kvidx, key, val);
+  RCRET(rc);
+  sblk->pi[idx] = kvidx;
+  sblk->flags |= SBLK_DURTY;
+  return 0;
+}
+
+IW_INLINE iwrc _sblk_rmkv(SBLK *sblk, uint8_t idx) {
+  iwrc rc;
+  KVBLK *kvblk = sblk->kvblk;
+  assert(kvblk);
+  IWFS_FSM *fsm = &kvblk->db->iwkv->fsm;
+  assert(idx < sblk->pnum && sblk->pi[idx] < KVBLK_IDXNUM);
+  rc = _kvblk_rmkv(kvblk, sblk->pi[idx], 0);
+  RCRET(rc);
+  sblk->pnum--;
+  sblk->flags |= SBLK_DURTY;
+  if (idx < sblk->pnum && sblk->pnum > 0) {
+    memmove(sblk->pi + idx, sblk->pi + idx + 1, sblk->pnum - idx);
+  }
+  if (idx == 0) {
+    uint8_t *mm;
+    rc = fsm->acquire_mmap(fsm, 0, &mm, 0);
+    RCRET(rc);
+    // Lowest key removed, replace it with the next key or reset
+    if (sblk->pnum > 0) {
+      uint32_t klen;
+      uint8_t *kbuf, *mm, lkl;
+      _kvblk_peek_key(sblk->kvblk, sblk->pi[idx], mm, &kbuf, &klen);
+      lkl = MIN(SBLK_LKLEN, klen);
+      _mm_set_u1(mm, sblk->addr + SOFF_LKL_U1, lkl);
+      memcpy(mm + sblk->addr + SOFF_LK_U61, kbuf, lkl);
+      if (lkl <= SBLK_LKLEN) {
+        sblk->flags |= SBLK_FULL_LKEY;
+      } else {
+        sblk->flags &= ~SBLK_FULL_LKEY;
+      }
+    } else {
+      _mm_set_u1(mm, sblk->addr + SOFF_LKL_U1, 0);
+    }
+    fsm->release_mmap(fsm);
+  }
+  return rc;
+}
+
+IW_INLINE iwrc _sblk_create2(IWLCTX *lx,
+                             int8_t nlevel,
+                             int8_t kvbpow,
+                             const IWKV_val *key,
+                             IWKV_val *val,
+                             SBLK **oblk) {
+  SBLK *sblk;
+  *oblk = 0;
+  iwrc rc = _sblk_create(lx, nlevel, kvbpow, &sblk);
+  RCRET(rc);
+  rc = _sblk_addkv(sblk, key, val);
+  if (rc) {
+    _sblk_destroy(lx, &sblk);
+  } else {
+    *oblk = sblk;
+  }
+  return rc;
+}

 //--------------------------  PUBLIC API


[PATCH] make drivers/net/e1000/e1000_hw.c:e1000_phy_igp_get_info() static

This patch makes the needlessly global e1000_phy_igp_get_info() static.

Signed-off-by: Adrian Bunk <0b86548ef377da0031a3ff3f0c4e06f016e20105@stusta.de>
Signed-off-by: Jeff Garzik <f3e731dfa293c7a83119d8aacfa41b5d2d780be9@garzik.org>


Update rcl_wait_set_add_* calls (#248)

Update rcl_wait_set_add_* calls (#248)

Now the functions take an optional output index argument.

--- rclpy/src/rclpy/_rclpy.c
+++ rclpy/src/rclpy/_rclpy.c
@@ -2251,23 +2251,23 @@
   if (0 == strcmp(entity_type, "subscription")) {
     rcl_subscription_t * subscription =
       (rcl_subscription_t *)PyCapsule_GetPointer(pyentity, "rcl_subscription_t");
-    ret = rcl_wait_set_add_subscription(wait_set, subscription);
+    ret = rcl_wait_set_add_subscription(wait_set, subscription, NULL);
   } else if (0 == strcmp(entity_type, "client")) {
     rcl_client_t * client =
       (rcl_client_t *)PyCapsule_GetPointer(pyentity, "rcl_client_t");
-    ret = rcl_wait_set_add_client(wait_set, client);
+    ret = rcl_wait_set_add_client(wait_set, client, NULL);
   } else if (0 == strcmp(entity_type, "service")) {
     rcl_service_t * service =
       (rcl_service_t *)PyCapsule_GetPointer(pyentity, "rcl_service_t");
-    ret = rcl_wait_set_add_service(wait_set, service);
+    ret = rcl_wait_set_add_service(wait_set, service, NULL);
   } else if (0 == strcmp(entity_type, "timer")) {
     rcl_timer_t * timer =
       (rcl_timer_t *)PyCapsule_GetPointer(pyentity, "rcl_timer_t");
-    ret = rcl_wait_set_add_timer(wait_set, timer);
+    ret = rcl_wait_set_add_timer(wait_set, timer, NULL);
   } else if (0 == strcmp(entity_type, "guard_condition")) {
     rcl_guard_condition_t * guard_condition =
       (rcl_guard_condition_t *)PyCapsule_GetPointer(pyentity, "rcl_guard_condition_t");
-    ret = rcl_wait_set_add_guard_condition(wait_set, guard_condition);
+    ret = rcl_wait_set_add_guard_condition(wait_set, guard_condition, NULL);
   } else {
     ret = RCL_RET_ERROR;  // to avoid a linter warning
     PyErr_Format(PyExc_RuntimeError,


Return `MBEDTLS_ERR_CCM_AUTH_FAILED` where needed.

On authentication decryption, when the driver returns the relevant error,
return `MBEDTLS_ERR_CCM_AUTH_FAILED`.

--- features/cryptocell/FEATURE_CRYPTOCELL310/ccm_alt.c
+++ features/cryptocell/FEATURE_CRYPTOCELL310/ccm_alt.c
@@ -130,10 +130,23 @@

     CrysRet =  CRYS_AESCCM( SASI_AES_DECRYPT, ctx->cipher_key, ctx->keySize_ID,(uint8_t*)iv, iv_len,
                             (uint8_t*)add, add_len,  (uint8_t*)input, length, output, tag_len, (uint8_t*)tag );
-    if ( CrysRet != CRYS_OK )
-        return ( MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED );
+    if( CrysRet == CRYS_FATAL_ERROR )
+    {
+        /*
+         * Unfortunately, Crys AESCCM returns CRYS_FATAL_ERROR when
+         * MAC isn't as expected.
+         */
+        ret = MBEDTLS_ERR_CCM_AUTH_FAILED;
+        goto exit;
+    }
+    else if ( CrysRet != CRYS_OK )
+    {
+        ret = MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED;
+        goto exit;
+    }

-    return ( 0 );
+exit:
+    return( ret );

 }


Server returns surrogate diagnostic 14: "System error in presenting records" when single record cannot be converted to XML.

--- ztest/ztest.c
+++ ztest/ztest.c
@@ -2,7 +2,7 @@
  * Copyright (c) 1995-2004, Index Data.
  * See the file LICENSE for details.
  *
- * $Id: ztest.c,v 1.64 2004-05-10 10:46:42 adam Exp $
+ * $Id: ztest.c,v 1.65 2004-09-30 21:54:22 adam Exp $
  */

 /*
@@ -489,12 +489,20 @@
         fread (r->record, size, 1, f);
         fclose (f);
     }
-    else if (r->request_format == VAL_TEXT_XML &&
-             (cp = dummy_xml_record (r->number, r->stream)))
-    {
-        r->len = strlen(cp);
-        r->record = cp;
-        r->output_format = VAL_TEXT_XML;
+    else if (r->request_format == VAL_TEXT_XML)
+    {
+	if ((cp = dummy_xml_record (r->number, r->stream)))
+	{
+	    r->len = strlen(cp);
+	    r->record = cp;
+	    r->output_format = VAL_TEXT_XML;
+	}
+	else
+	{
+	    r->errcode = 14;
+	    r->surrogate_flag = 1;
+	    return 0;
+	}
     }
     else if ((cp = dummy_marc_record(r->number, r->stream)))
     {


modify comments about Stream method

modify comments about Stream method

--- apps/include/SerialPort.h
+++ apps/include/SerialPort.h
@@ -12,7 +12,7 @@
 typedef struct {
 	/**
 	 * ストリームから1byte読み込む
-	 * @return 読み込んだデータ
+	 * @return 読み込んだデータ，データがない場合は0を返す
 	 */
 	uint8_t (*read)(void);
 } ByteInputStream;
@@ -20,7 +20,7 @@
 typedef struct {
 	/**
 	 * ストリームに1byte書き込む
-	 * @param data 書き込むデータ
+	 * @param data 書き込むデータ，0を書き込んでも送信しない
 	 */
 	void (*write)(uint8_t data);
 } ByteOutputStream;


e1000e: 82577/8/9 mis-configured OEM bits during S0->Sx

The LPLU (Low Power Link Up) and Gigabit Disable bits (a.k.a. OEM bits)
were being configured incorrectly when device goes to D3 state.

Signed-off-by: Bruce Allan <9ca9a0356a10eed24a8d9ec38dc19d9cd20ba07b@intel.com>
Tested-by: Jeff Pieper <89ae28dca346dcf475c1c4c5ccad0a12c81be577@intel.com>
Signed-off-by: Jeff Kirsher <87e35f5be20bb3e67f4ba6b86f5f6be3085b1b3a@intel.com>

--- drivers/net/e1000e/ich8lan.c
+++ drivers/net/e1000e/ich8lan.c
@@ -3591,7 +3591,7 @@
 	ew32(PHY_CTRL, phy_ctrl);

 	if (hw->mac.type >= e1000_pchlan) {
-		e1000_oem_bits_config_ich8lan(hw, true);
+		e1000_oem_bits_config_ich8lan(hw, false);
 		ret_val = hw->phy.ops.acquire(hw);
 		if (ret_val)
 			return;


Fix diagnostic for MARC and present request out of range

--- ztest/ztest.c
+++ ztest/ztest.c
@@ -522,6 +522,7 @@
         if (!cp)
         {
             r->errcode = YAZ_BIB1_PRESENT_REQUEST_OUT_OF_RANGE;
+            return 0;
         }
         else
         {


UnboundedBlockingQueue: Adjust segment size

Summary: Adjust the segment size of the `UnboundedQueue` to 64 instead of 256, a size more suitable for CPUThreadPoolExecutor::CPUTask elements.

Reviewed By: djwatson

Differential Revision: D6665918

fbshipit-source-id: c34c4fa936ee5c6d6a3dd4489129c936369f3980

--- folly/executors/task_queue/UnboundedBlockingQueue.h
+++ folly/executors/task_queue/UnboundedBlockingQueue.h
@@ -46,7 +46,7 @@

  private:
   LifoSem sem_;
-  UMPMCQueue<T, false> queue_;
+  UMPMCQueue<T, false, 6> queue_;
 };

 } // namespace folly


net/ena: update version to 2.6.0

net/ena: update version to 2.6.0

This release contains multiple bug fixes and improvements, including
  - Removal of the linearization function from the xmit Tx path. The
    DPDK assumes checking for the mbuf segments number in the Tx prepare
    function.
  - Extra logs, statistics, checks...
  - Cleanup of the unused variables and definitions.
  - Configurable Link Status event.
  - Improvements for the timer service and the reset.
  - Usage of the optimized memcpy on ARM.
  - MP awareness improvements - extra API support for the secondary
    processes (like reading basic statistics).
  - Support of the xstats API to get xstat names by ID.
  - Configurable Tx completions timeout.
  - Proper setting of the meta-descriptor's DF flag.

Signed-off-by: Michal Krawczyk <a91dcbb4df49d8bfe0a9930d7ff911a4292ca1f5@semihalf.com>

--- drivers/net/ena/ena_ethdev.c
+++ drivers/net/ena/ena_ethdev.c
@@ -21,7 +21,7 @@
 #include <ena_eth_io_defs.h>

 #define DRV_MODULE_VER_MAJOR	2
-#define DRV_MODULE_VER_MINOR	5
+#define DRV_MODULE_VER_MINOR	6
 #define DRV_MODULE_VER_SUBMINOR	0

 #define __MERGE_64B_H_L(h, l) (((uint64_t)h << 32) | l)


net/enic: fix the MTU handler to rely on max packet length

The RQ setup functions (enic_alloc_rq and enic_alloc_rx_queue_mbufs)
have changed to rely on max_rx_pkt_len to determine the use of scatter
and buffer size. But, the MTU handler only updates ethdev's MTU
value. So make it update max_rx_pkt_len as well. Other PMDs also
update both mtu and max_rx_pkt_len in their MTU handlers.

Also the condition for taking a short cut (scatter is disabled) in the
MTU handler is wrong. Even when scatter is disabled, a change in
max_rx_pkt_len may affect the buffer size posted to the NIC. So remove
that condition.

Finally, fix a comment and a warning message condition.

Fixes: 422ba91716a7 ("net/enic: heed the requested max Rx packet size")

Signed-off-by: Hyong Youb Kim <410cadac1eb3154f1b3752aedc2559ad69f3863e@cisco.com>
Reviewed-by: John Daley <097981eb5abe5dbeac3142a4f5a88742d916de86@cisco.com>
Reviewed-by: Aaron Conole <aa17ba42a0685b214660ffb377dc7569a94d48c9@redhat.com>

--- drivers/net/enic/enic_main.c
+++ drivers/net/enic/enic_main.c
@@ -287,7 +287,7 @@
 		  rq->ring.desc_count);

 	/*
-	 * If *not* using scatter and the mbuf size is smaller than the
+	 * If *not* using scatter and the mbuf size is greater than the
 	 * requested max packet size (max_rx_pkt_len), then reduce the
 	 * posted buffer size to max_rx_pkt_len. HW still receives packets
 	 * larger than max_rx_pkt_len, but they will be truncated, which we
@@ -730,7 +730,7 @@
 		 * See enic_alloc_rx_queue_mbufs().
 		 */
 		if (max_rx_pkt_len <
-		    enic_mtu_to_max_rx_pktlen(enic->rte_dev->data->mtu)) {
+		    enic_mtu_to_max_rx_pktlen(enic->max_mtu)) {
 			dev_warning(enic, "rxmode.max_rx_pkt_len is ignored"
 				    " when scatter rx mode is in use.\n");
 		}
@@ -1416,20 +1416,26 @@
 			"MTU (%u) is greater than value configured in NIC (%u)\n",
 			new_mtu, config_mtu);

-	/* The easy case is when scatter is disabled. However if the MTU
-	 * becomes greater than the mbuf data size, packet drops will ensue.
+	/* Update the MTU and maximum packet length */
+	eth_dev->data->mtu = new_mtu;
+	eth_dev->data->dev_conf.rxmode.max_rx_pkt_len =
+		enic_mtu_to_max_rx_pktlen(new_mtu);
+
+	/*
+	 * If the device has not started (enic_enable), nothing to do.
+	 * Later, enic_enable() will set up RQs reflecting the new maximum
+	 * packet length.
 	 */
-	if (!(enic->rte_dev->data->dev_conf.rxmode.offloads &
-	      DEV_RX_OFFLOAD_SCATTER)) {
-		eth_dev->data->mtu = new_mtu;
+	if (!eth_dev->data->dev_started)
 		goto set_mtu_done;
-	}
-
-	/* Rx scatter is enabled so reconfigure RQ's on the fly. The point is to
-	 * change Rx scatter mode if necessary for better performance. I.e. if
-	 * MTU was greater than the mbuf size and now it's less, scatter Rx
-	 * doesn't have to be used and vice versa.
-	  */
+
+	/*
+	 * The device has started, re-do RQs on the fly. In the process, we
+	 * pick up the new maximum packet length.
+	 *
+	 * Some applications rely on the ability to change MTU without stopping
+	 * the device. So keep this behavior for now.
+	 */
 	rte_spinlock_lock(&enic->mtu_lock);

 	/* Stop traffic on all RQs */
@@ -1454,8 +1460,6 @@

 	/* now it is safe to reconfigure the RQs */

-	/* update the mtu */
-	eth_dev->data->mtu = new_mtu;

 	/* free and reallocate RQs with the new MTU */
 	for (rq_idx = 0; rq_idx < enic->rq_count; rq_idx++) {


enic: bug fix: enable VLAN filtering

enic: bug fix: enable VLAN filtering

Bug fix: enable VLAN filtering

Signed-off-by: Scott Feldman <449bf119f7579fb76e3031d058c77d976b1c4652@cisco.com>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>

--- drivers/net/enic/enic_main.c
+++ drivers/net/enic/enic_main.c
@@ -1968,7 +1968,8 @@
 		break;
 	}

-	netdev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
+	netdev->features |= NETIF_F_HW_VLAN_TX |
+		NETIF_F_HW_VLAN_RX | NETIF_F_HW_VLAN_FILTER;
 	if (ENIC_SETTING(enic, TXCSUM))
 		netdev->features |= NETIF_F_SG | NETIF_F_HW_CSUM;
 	if (ENIC_SETTING(enic, TSO))


Persist public chat topic through restart

git-svn-id: fa0849429efd6140f8c6b0411d4b758884714b35@6902 94223b32-352b-4d6d-a509-7b239cf53eea

--- wired/chats.c
+++ wired/chats.c
@@ -64,16 +64,21 @@
 static void							wd_chat_dealloc(wi_runtime_instance_t *);
 static wi_string_t *				wd_chat_description(wi_runtime_instance_t *);

+static wd_cid_t						wd_chat_random_id(void);
+
 static wd_topic_t *					wd_topic_alloc(void);
 static wd_topic_t *					wd_topic_init_with_user_and_string(wd_topic_t *, wd_user_t *, wi_string_t *);
+static wd_topic_t *					wd_topic_init_with_dictionary(wd_topic_t *, wi_dictionary_t *);
 static void							wd_topic_dealloc(wi_runtime_instance_t *);

-static wd_cid_t						wd_chat_random_id(void);
+static wi_dictionary_t *			wd_topic_dictionary(wd_topic_t *topic);

 wd_chat_t							*wd_public_chat;

 static wi_dictionary_t				*wd_chats;
+
+static wi_string_t					*wd_topic_path;

 static wi_runtime_id_t				wd_chat_runtime_id = WI_RUNTIME_ID_NULL;
 static wi_runtime_class_t			wd_chat_runtime_class = {
@@ -97,13 +102,22 @@

 void wd_chats_init(void) {
+	wi_runtime_instance_t	*instance;
+
 	wd_chat_runtime_id = wi_runtime_register_class(&wd_chat_runtime_class);
 	wd_topic_runtime_id = wi_runtime_register_class(&wd_topic_runtime_class);

 	wd_chats = wi_dictionary_init(wi_dictionary_alloc());

+	wd_topic_path = WI_STR("topic");
+
 	wd_public_chat = wd_chat_init_public_chat(wd_chat_alloc());
 	wd_chats_add_chat(wd_public_chat);
+
+	instance = wi_plist_read_instance_from_file(wd_topic_path);
+
+	if(instance && wi_runtime_id(instance) == wi_dictionary_runtime_id())
+		wd_public_chat->topic = wd_topic_init_with_dictionary(wd_topic_alloc(), instance);
 }

@@ -361,6 +375,11 @@
 	wi_release(chat->topic);
 	chat->topic = topic;
 	wi_recursive_lock_unlock(chat->lock);
+
+	if(chat->id == WD_PUBLIC_CHAT_ID) {
+		if(!wi_plist_write_instance_to_file(wd_topic_dictionary(topic), wd_topic_path))
+			wi_log_err(WI_STR("Could not write to %@: %m"), wd_topic_path);
+	}
 }

@@ -417,6 +436,22 @@

+static wd_topic_t * wd_topic_init_with_dictionary(wd_topic_t *topic, wi_dictionary_t *dictionary) {
+	topic->topic	= wi_retain(wi_dictionary_data_for_key(dictionary, WI_STR("wired.chat.topic.topic")));
+	topic->date		= wi_retain(wi_dictionary_data_for_key(dictionary, WI_STR("wired.chat.topic.time")));
+	topic->nick		= wi_retain(wi_dictionary_data_for_key(dictionary, WI_STR("wired.user.nick")));
+
+	if(!topic->topic || !topic->date || !topic->nick) {
+		wi_release(topic);
+
+		return NULL;
+	}
+
+	return topic;
+}
+
+
+
 static void wd_topic_dealloc(wi_runtime_instance_t *instance) {
 	wd_topic_t		*topic = instance;

@@ -424,3 +459,15 @@
 	wi_release(topic->date);
 	wi_release(topic->nick);
 }
+
+
+
+#pragma mark -
+
+static wi_dictionary_t * wd_topic_dictionary(wd_topic_t *topic) {
+	return wi_dictionary_with_data_and_keys(
+		topic->topic,	WI_STR("wired.chat.topic.topic"),
+		topic->date,	WI_STR("wired.chat.topic.time"),
+		topic->nick,	WI_STR("wired.user.nick"),
+		NULL);
+}


some code style fixes

some code style fixes

--- qrgui/view/editorViewMVIface.h
+++ qrgui/view/editorViewMVIface.h
@@ -1,6 +1,7 @@
 #pragma once

 #include <QAbstractItemView>
+
 #include "../models/graphicalModelAssistApi.h"
 #include "../models/logicalModelAssistApi.h"


ethoc: set addr_assign_type if random_ether_addr() used

Set addr_assign_type correctly to NET_ADDR_RANDOM in case
a random MAC address was generated and assigned to the netdevice.

Fixed ethoc_set_mac_address() to check if the given mac
address is valid and set also dev_addr of the net_device.
Check also the return value of ethoc_set_mac_address() in
ethoc_probe().

Reset the state to NET_ADDR_PERM as soon as the MAC get
changed via .ndo_set_mac_address.

v2: set net_device->dev_addr in ethoc_set_mac_address(),
    check if given address is valid

Signed-off-by: Danny Kukawka <63fc4e4777fd9fe63fce3d8f37e21b54b0cdb9e8@bisect.de>

--- drivers/net/ethernet/ethoc.c
+++ drivers/net/ethernet/ethoc.c
@@ -776,9 +776,15 @@
 	struct ethoc *priv = netdev_priv(dev);
 	u8 *mac = (u8 *)addr;

+	if (!is_valid_ether_addr(mac))
+		return -EADDRNOTAVAIL;
+
 	ethoc_write(priv, MAC_ADDR0, (mac[2] << 24) | (mac[3] << 16) |
 				     (mac[4] <<  8) | (mac[5] <<  0));
 	ethoc_write(priv, MAC_ADDR1, (mac[0] <<  8) | (mac[1] <<  0));
+
+	memcpy(dev->dev_addr, mac, ETH_ALEN);
+	dev->addr_assign_type &= ~NET_ADDR_RANDOM;

 	return 0;
 }
@@ -909,6 +915,7 @@
 	unsigned int phy;
 	int num_bd;
 	int ret = 0;
+	bool random_mac = false;

 	/* allocate networking device */
 	netdev = alloc_etherdev(sizeof(struct ethoc));
@@ -1049,10 +1056,19 @@

 	/* Check the MAC again for validity, if it still isn't choose and
 	 * program a random one. */
-	if (!is_valid_ether_addr(netdev->dev_addr))
+	if (!is_valid_ether_addr(netdev->dev_addr)) {
 		random_ether_addr(netdev->dev_addr);
-
-	ethoc_set_mac_address(netdev, netdev->dev_addr);
+		random_mac = true;
+	}
+
+	ret = ethoc_set_mac_address(netdev, netdev->dev_addr);
+	if (ret) {
+		dev_err(&netdev->dev, "failed to set MAC address\n");
+		goto error;
+	}
+
+	if (random_mac)
+		netdev->addr_assign_type |= NET_ADDR_RANDOM;

 	/* register MII bus */
 	priv->mdio = mdiobus_alloc();


fixed bug in MP12E2

fixed bug in MP12E2

--- wlancap2hcx.c
+++ wlancap2hcx.c
@@ -1144,6 +1144,7 @@
 return;
 }
 /*===========================================================================*/
+/*
 static void lookfor21(long int cakt, eapdb_t *zeigerakt, unsigned long long int replaycakt)
 {
 eapdb_t *zeiger;
@@ -1181,6 +1182,7 @@
 	}
 return;
 }
+*/
 /*===========================================================================*/
 static void lookfor12(long int cakt, eapdb_t *zeigerakt, unsigned long long int replaycakt)
 {
@@ -1272,10 +1274,12 @@
 m = geteapkey(neweapdbdata->eapol);

 replaycount = getreplaycount(neweapdbdata->eapol);
+/*
 if(m == 1)
 	{
 	lookfor21(eapdbrecords, neweapdbdata, replaycount);
 	}
+*/

 if(m == 2)
 	{


net/i40e: fix flow director MAC rule creation

This patch fixes the issue that the flow which both source MAC mask
and destination MAC mask are all zeros can not be created.

Fixes: ea0c22fd8227 ("net/i40e: enable MAC address as flow director input set")

Signed-off-by: Shougang Wang <f5a73e725f8d9cee87ff8146ba570071ef540761@intel.com>
Tested-by: Hailin Xu <708ec1cf699459553152514923730b4ce5c316b3@intel.com>
Reviewed-by: Jeff Guo <62aa901f8680899d1e8b3d9b45cf4843c2976e1c@intel.com>

--- drivers/net/i40e/i40e_flow.c
+++ drivers/net/i40e/i40e_flow.c
@@ -2643,7 +2643,8 @@
 					filter->input.flow.l2_flow.src =
 						eth_spec->src;
 					input_set |= (I40E_INSET_DMAC | I40E_INSET_SMAC);
-				} else {
+				} else if (!rte_is_zero_ether_addr(&eth_mask->src) ||
+					   !rte_is_zero_ether_addr(&eth_mask->dst)) {
 					rte_flow_error_set(error, EINVAL,
 						      RTE_FLOW_ERROR_TYPE_ITEM,
 						      item,


removed wps debug info

removed wps debug info

--- wlandump-ng.c
+++ wlandump-ng.c
@@ -413,8 +413,6 @@
 wpsd = (wps_t*)(eapext->data);
 if((memcmp(wpsd->vid, WPS_VENDOR, sizeof(wpsd->vid)) != 0) || (be32toh(wpsd->type) != WPS_SIMPLECONF))
 	return 0;
-
-printf("%ld\n", EAPEXT_SIZE);

 int vtagl = be16toh(eapext->eaplen);
 vtag = (vtag_t*)(wpsd->tags);


Memory leak fix: map_free() noew frees the map

--- champlain/champlain-map.c
+++ champlain/champlain-map.c
@@ -168,6 +168,7 @@
 map_free (Map *map)
 {
   g_object_unref (map->current_level);
+  g_free (map);
 }

 gboolean


net/iavf: support RSS for IPv6 64-bit prefix

RSS for IPv6 prefix 64bit fields are supported in this patch, so that
we can use prefix instead of full IPv6 address for RSS. The prefix
here only includes the first 64 bits of both SRC and DST IPv6 address.

Signed-off-by: Junfeng Guo <4e83c95a099a2e36f95a0baa7b159dfaca2b98e9@intel.com>
Acked-by: Qi Zhang <9e9e58ffa71a29bb7b87766b362515be648fcbe0@intel.com>

--- drivers/net/iavf/iavf_hash.c
+++ drivers/net/iavf/iavf_hash.c
@@ -541,6 +541,11 @@

 #define REFINE_PROTO_FLD(op, fld) \
 	VIRTCHNL_##op##_PROTO_HDR_FIELD(hdr, VIRTCHNL_PROTO_HDR_##fld)
+#define REPALCE_PROTO_FLD(fld_1, fld_2) \
+do { \
+	REFINE_PROTO_FLD(DEL, fld_1);	\
+	REFINE_PROTO_FLD(ADD, fld_2);	\
+} while (0)

 /* refine proto hdrs base on l2, l3, l4 rss type */
 static void
@@ -596,6 +601,14 @@
 			} else {
 				hdr->field_selector = 0;
 			}
+			if (rss_type & RTE_ETH_RSS_L3_PRE64) {
+				if (REFINE_PROTO_FLD(TEST, IPV6_SRC))
+					REPALCE_PROTO_FLD(IPV6_SRC,
+							  IPV6_PREFIX64_SRC);
+				if (REFINE_PROTO_FLD(TEST, IPV6_DST))
+					REPALCE_PROTO_FLD(IPV6_DST,
+							  IPV6_PREFIX64_DST);
+			}
 			break;
 		case VIRTCHNL_PROTO_HDR_UDP:
 			if (rss_type &
@@ -763,6 +776,16 @@
 		if (__builtin_popcountll(rss_type & invalid_rss_comb[i]) > 1)
 			return true;
 	}
+
+	/* current ipv6 prefix only supports prefix 64 bits*/
+#define _invalid_prefix_ (RTE_ETH_RSS_L3_PRE32	| \
+			  RTE_ETH_RSS_L3_PRE40	| \
+			  RTE_ETH_RSS_L3_PRE48	| \
+			  RTE_ETH_RSS_L3_PRE56	| \
+			  RTE_ETH_RSS_L3_PRE96)
+
+	if (rss_type & _invalid_prefix_)
+		return true;

 	/* check not allowed RSS type */
 #define _RSS_ATTR_ (ETH_RSS_L3_SRC_ONLY		| \


fixed typo

fixed typo

--- wlanhcxinfo.c
+++ wlanhcxinfo.c
@@ -384,7 +384,7 @@
 			"WPA1 RC4 Cipher, HMAC-MD5.........: %ld\n"
 			"WPA2 AES Cipher, HMAC-SHA1........: %ld\n"
 			"WPA2 AES Cipher, AES-128-CMAC.....: %ld\n"
-			"Group key flag set................: %ld\n"
+			"group key flag set................: %ld\n"
 			"message pair M12E2................: %ld (%ld not replaycount checked)\n"
 			"message pair M14E4................: %ld (%ld not replaycount checked)\n"
 			"message pair M32E2................: %ld (%ld not replaycount checked)\n"


net/ice: fix link speed

net/ice: fix link speed

Fix the issue that the link speed is unknown.

Fixes: 690175ee51bf ("net/ice: support getting device information")
Fixes: cf911d90e366 ("net/ice: support link update")

Signed-off-by: Wenzhuo Lu <58cb9036bdff9a5412edc3b9f70e105ccf59954f@intel.com>
Acked-by: Qi Zhang <9e9e58ffa71a29bb7b87766b362515be648fcbe0@intel.com>

--- drivers/net/ice/ice_ethdev.c
+++ drivers/net/ice/ice_ethdev.c
@@ -1899,7 +1899,9 @@
 			       ETH_LINK_SPEED_10G |
 			       ETH_LINK_SPEED_20G |
 			       ETH_LINK_SPEED_25G |
-			       ETH_LINK_SPEED_40G;
+			       ETH_LINK_SPEED_40G |
+			       ETH_LINK_SPEED_50G |
+			       ETH_LINK_SPEED_100G;

 	dev_info->nb_rx_queues = dev->data->nb_rx_queues;
 	dev_info->nb_tx_queues = dev->data->nb_tx_queues;
@@ -2009,6 +2011,12 @@
 		break;
 	case ICE_AQ_LINK_SPEED_40GB:
 		link.link_speed = ETH_SPEED_NUM_40G;
+		break;
+	case ICE_AQ_LINK_SPEED_50GB:
+		link.link_speed = ETH_SPEED_NUM_50G;
+		break;
+	case ICE_AQ_LINK_SPEED_100GB:
+		link.link_speed = ETH_SPEED_NUM_100G;
 		break;
 	case ICE_AQ_LINK_SPEED_UNKNOWN:
 	default:


net/ice: fix link up when starting device

Currently, there is a possibility that the link status is not correct
after set link up, the device ID is 159b. It would be fixed by calling
ice_link_update() while the parameter 'wait_to_complete' is true. It's
reasonable to wait for complete right after set link up as it is not
in an link status change interrupt handling scenario.

Fixes: cf911d90e366 ("net/ice: support link update")
Cc: stable@dpdk.org

Signed-off-by: Yunjian Wang <9985a735d5d5f80ef648228b285228d6eb6eaf45@huawei.com>
Acked-by: Qi Zhang <9e9e58ffa71a29bb7b87766b362515be648fcbe0@intel.com>

--- drivers/net/ice/ice_ethdev.c
+++ drivers/net/ice/ice_ethdev.c
@@ -3610,7 +3610,7 @@
 	ice_dev_set_link_up(dev);

 	/* Call get_link_info aq command to enable/disable LSE */
-	ice_link_update(dev, 0);
+	ice_link_update(dev, 1);

 	pf->adapter_stopped = false;


Changed sync default to group 1 only.

Changed sync default to group 1 only.

--- wled00/wled.h
+++ wled00/wled.h
@@ -298,8 +298,8 @@
 WLED_GLOBAL uint16_t liveHSVSaturation _INIT(13);
 WLED_GLOBAL uint16_t liveHSVValue _INIT(10);

-WLED_GLOBAL uint8_t syncGroups    _INIT(0xFF);                    // sync groups this instance syncs (bit mapped)
-WLED_GLOBAL uint8_t receiveGroups _INIT(0xFF);                    // sync receive groups this instance belongs to (bit mapped)
+WLED_GLOBAL uint8_t syncGroups    _INIT(0x01);                    // sync groups this instance syncs (bit mapped)
+WLED_GLOBAL uint8_t receiveGroups _INIT(0x01);                    // sync receive groups this instance belongs to (bit mapped)
 WLED_GLOBAL bool receiveNotificationBrightness _INIT(true);       // apply brightness from incoming notifications
 WLED_GLOBAL bool receiveNotificationColor      _INIT(true);       // apply color
 WLED_GLOBAL bool receiveNotificationEffects    _INIT(true);       // apply effects setup


view_ needs to be destroyed after web_contents_

--- brightray/browser/inspectable_web_contents_impl.h
+++ brightray/browser/inspectable_web_contents_impl.h
@@ -160,9 +160,9 @@
   PendingRequestsMap pending_requests_;
   InspectableWebContentsDelegate* delegate_;  // weak references.

-  scoped_ptr<InspectableWebContentsView> view_;
   scoped_ptr<content::WebContents> web_contents_;
   scoped_ptr<content::WebContents> devtools_web_contents_;
+  scoped_ptr<InspectableWebContentsView> view_;

   base::WeakPtrFactory<InspectableWebContentsImpl> weak_factory_;


INTEGRATION: CWS kso11 (1.3.8); FILE MERGED 2004/03/10 15:45:29 kso 1.3.8.1: #115883# - Use osl Security when creating pipes.

--- jurt/source/pipe/com_sun_star_lib_connections_pipe_PipeConnection.c
+++ jurt/source/pipe/com_sun_star_lib_connections_pipe_PipeConnection.c
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: com_sun_star_lib_connections_pipe_PipeConnection.c,v $
  *
- *  $Revision: 1.3 $
- *
- *  last change: $Author: hr $ $Date: 2004-02-04 12:14:32 $
+ *  $Revision: 1.4 $
+ *
+ *  last change: $Author: kz $ $Date: 2004-03-25 11:04:12 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -63,24 +63,16 @@
 #include <config.h>
 #endif

+#include "osl/security.h"
 #include <osl/pipe.h>

 #include "com_sun_star_lib_connections_pipe_PipeConnection.h"

 /*****************************************************************************/
 /* exception macros */
-
-#define Throw_IfException(env) { \
-    if ((*env)->ExceptionOccurred(env) != NULL) break; }

 #define ThrowException(env, type, msg) { \
     (*env)->ThrowNew(env, (*env)->FindClass(env, type), msg); }
-
-#define ThrowIO_If(cond, env, msg) { if (cond) \
-    { ThrowException(env, "com/sun/star/io/IOException", msg); break; } }
-
-#define ThrowRT_If(cond, env, msg) { if (cond) \
-    { ThrowException(env, "java/lang/RuntimeException", msg); break; } }

 /*****************************************************************************/
 /* helper functions prototypes */
@@ -98,11 +90,22 @@
     while (1)
     {
         tclass  = (*env)->GetObjectClass(env, obj_this);
-        ThrowRT_If((tclass == NULL),
-            env, "native pipe cannot find class");
+        if (tclass == NULL)
+        {
+            ThrowException(env,
+                           "java/lang/RuntimeException",
+                           "native pipe cannot find class");
+            break;
+        }
+
         fid     = (*env)->GetFieldID(env, tclass, "_nPipeHandle", "J");
-        ThrowRT_If((fid == NULL),
-            env, "native pipe cannot find field");
+        if (fid == NULL)
+        {
+            ThrowException(env,
+                           "java/lang/RuntimeException",
+                           "native pipe cannot find field");
+            break;
+        }
         return ((oslPipe)((*env)->GetLongField(env, obj_this, fid)));
     }
     return NULL;
@@ -142,54 +145,100 @@
     jclass      tclass;
     jfieldID    fid;

+    oslSecurity     psec    = osl_getCurrentSecurity();
     oslPipe         npipe   = NULL;
     rtl_uString *   pname   = NULL;
     while (1)
     {
-        ThrowRT_If(((*env)->MonitorEnter(env, obj_this) != 0),
-            env, "native pipe cannot synchronize on the object");
+        if ((*env)->MonitorEnter(env, obj_this) != 0)
+        {
+            ThrowException(env,
+                           "java/lang/RuntimeException",
+                           "native pipe cannot synchronize on the object");
+            break;
+        }
         state   = INMONITOR;

         /* check connection state */
         npipe   = getPipe(env, obj_this);
-        Throw_IfException(env);
-        ThrowIO_If((npipe != NULL),
-            env, "native pipe is already connected");
+        if ((*env)->ExceptionOccurred(env) != NULL)
+            break;
+        if (npipe != NULL)
+        {
+            ThrowException(env,
+                           "com/sun/star/io/IOException",
+                           "native pipe is already connected");
+            break;
+        }

         /* save the pipe name */
         tclass  = (*env)->GetObjectClass(env, obj_this);
-        ThrowRT_If((tclass == NULL),
-            env, "native pipe cannot find class");
+        if (tclass == NULL)
+        {
+            ThrowException(env,
+                           "java/lang/RuntimeException",
+                           "native pipe cannot find class");
+            break;
+        }
+
         fid     = (*env)->GetFieldID(env, tclass,
             "_aDescription", "Ljava/lang/String;");
-        ThrowRT_If((fid == NULL),
-            env, "native pipe cannot find field");
+        if (fid == NULL)
+        {
+            ThrowException(env,
+                           "java/lang/RuntimeException",
+                           "native pipe cannot find field");
+            break;
+        }
+
         (*env)->SetObjectField(env, obj_this, fid, (jobject)name);

         /* convert pipe name to rtl_uString */
         pname   = jstring2ustring(env, name);
-        ThrowRT_If((pname == NULL),
-            env, "native pipe cannot convert name");
+        if (pname == NULL)
+        {
+            ThrowException(env,
+                           "java/lang/RuntimeException",
+                           "native pipe cannot convert name");
+            break;
+        }
         state   = GOTNAME;

         /* try to connect */
-        npipe   = osl_createPipe(pname, osl_Pipe_OPEN, NULL);
-        ThrowRT_If((npipe == NULL),
-            env, "cannot create native pipe");
+        npipe   = osl_createPipe(pname, osl_Pipe_OPEN, psec);
+        if (npipe == NULL)
+        {
+            ThrowException(env,
+                           "java/lang/RuntimeException",
+                           "cannot create native pipe");
+            break;
+        }
         state   = CREATED;

         /* save the pipe */
         tclass  = (*env)->GetObjectClass(env, obj_this);
-        ThrowRT_If((tclass == NULL),
-            env, "native pipe cannot find class");
+        if (tclass == NULL)
+        {
+            ThrowException(env,
+                           "java/lang/RuntimeException",
+                           "native pipe cannot find class");
+            break;
+        }
+
         fid     = (*env)->GetFieldID(env, tclass, "_nPipeHandle", "J");
-        ThrowRT_If((fid == NULL),
-            env, "native pipe cannot find field");
+        if (fid == NULL)
+        {
+            ThrowException(env,
+                           "java/lang/RuntimeException",
+                           "native pipe cannot find field");
+            break;
+        }
         (*env)->SetLongField(env, obj_this, fid, (jlong)npipe);

         /* done */
         rtl_uString_release(pname);
         (*env)->MonitorExit(env, obj_this);
+        osl_freeSecurityHandle(psec);
         return;
     }
     switch (state)
@@ -202,6 +251,7 @@
         case INMONITOR:
             (*env)->MonitorExit(env, obj_this);
         case START:
+            osl_freeSecurityHandle(psec);
         default:
             break;
     }
@@ -229,23 +279,46 @@

     while (1)
     {
-        ThrowRT_If(((*env)->MonitorEnter(env, obj_this) != 0),
-            env, "native pipe cannot synchronize on the object");
+        if ((*env)->MonitorEnter(env, obj_this) != 0)
+        {
+            ThrowException(env,
+                           "java/lang/RuntimeException",
+                           "native pipe cannot synchronize on the object");
+            break;
+        }
         state   = INMONITOR;

         /* check connection state */
         npipe   = getPipe(env, obj_this);
-        Throw_IfException(env);
-        ThrowIO_If((npipe == NULL),
-            env, "native pipe is not connected");
+        if ((*env)->ExceptionOccurred(env) != NULL)
+            break;
+        if (npipe == NULL)
+        {
+            ThrowException(env,
+                           "com/sun/star/io/IOException",
+                           "native pipe is not connected");
+            break;
+        }

         /* remove the reference to the pipe */
         tclass  = (*env)->GetObjectClass(env, obj_this);
-        ThrowRT_If((tclass == NULL),
-            env, "native pipe cannot find class");
+        if (tclass == NULL)
+        {
+            ThrowException(env,
+                           "java/lang/RuntimeException",
+                           "native pipe cannot find class");
+            break;
+        }
+
         fid     = (*env)->GetFieldID(env, tclass, "_nPipeHandle", "J");
-        ThrowRT_If((fid == NULL),
-            env, "native pipe cannot find field");
+        if (fid == NULL)
+        {
+            ThrowException(env,
+                           "java/lang/RuntimeException",
+                           "native pipe cannot find field");
+            break;
+        }
+
         (*env)->SetLongField(env, obj_this, fid, (jlong)0);

         /* release the pipe */
@@ -292,23 +365,40 @@
     while (1)
     {
         /* enter monitor */
-        ThrowRT_If(((*env)->MonitorEnter(env, obj_this) != 0),
-            env, "native pipe cannot synchronize on the object");
+        if ((*env)->MonitorEnter(env, obj_this) != 0)
+        {
+            ThrowException(env,
+                           "java/lang/RuntimeException",
+                           "native pipe cannot synchronize on the object");
+            break;
+        }
         state = INMONITOR;

         /* check connection state */
         npipe   = getPipe(env, obj_this);
-        Throw_IfException(env);
-        ThrowIO_If((npipe == NULL),
-            env, "native pipe is not connected");
+        if ((*env)->ExceptionOccurred(env) != NULL)
+            break;
+        if (npipe == NULL)
+        {
+            ThrowException(env,
+                           "com/sun/star/io/IOException",
+                           "native pipe is not connected");
+            break;
+        }

         /* aquire pipe */
         osl_acquirePipe( npipe );
         state = AQUIRED;

         /* allocate a buffer */
-        ThrowRT_If(((nbuff = malloc(len)) == NULL),
-            env, "native pipe out of memory");
+        if ((nbuff = malloc(len)) == NULL)
+        {
+            ThrowException(env,
+                           "java/lang/RuntimeException",
+                           "native pipe out of memory");
+            break;
+        }
+
         state = GOTBUFFER;

         /* exit monitor */
@@ -318,15 +408,26 @@
         nread = osl_readPipe(npipe, nbuff, len);

         /* enter monitor again */
-        ThrowRT_If(((*env)->MonitorEnter(env, obj_this) != 0),
-            env, "native pipe cannot synchronize on the object");
+        if ((*env)->MonitorEnter(env, obj_this) != 0)
+        {
+            ThrowException(env,
+                           "java/lang/RuntimeException",
+                           "native pipe cannot synchronize on the object");
+            break;
+        }

         /* copy buffer */
         if (nread >= 0)
         {
             bytes   = (*env)->NewByteArray(env, len);
-            ThrowRT_If((bytes == NULL),
-                env, "native pipe out of memory");
+            if (bytes == NULL)
+            {
+                ThrowException(env,
+                               "java/lang/RuntimeException",
+                               "native pipe out of memory");
+                break;
+            }
+
             /* save the data */
             (*env)->SetByteArrayRegion(env, bytes, 0, len, nbuff);
             (*env)->SetObjectArrayElement(env, buffer, 0, bytes);
@@ -378,28 +479,57 @@

     while (1)
     {
-        ThrowRT_If(((*env)->MonitorEnter(env, obj_this) != 0),
-            env, "native pipe cannot synchronize on the object");
+        if ((*env)->MonitorEnter(env, obj_this) != 0)
+        {
+            ThrowException(env,
+                           "java/lang/RuntimeException",
+                           "native pipe cannot synchronize on the object");
+            break;
+        }
         state   = INMONITOR;
+
         /* check connection state */
         npipe   = getPipe(env, obj_this);
-        Throw_IfException(env);
-        ThrowIO_If((npipe == NULL),
-            env, "native pipe is not connected");
+        if ((*env)->ExceptionOccurred(env) != NULL)
+            break;
+        if (npipe == NULL)
+        {
+            ThrowException(env,
+                           "com/sun/star/io/IOException",
+                           "native pipe is not connected");
+            break;
+        }
+
         nwrite  = (*env)->GetArrayLength(env, buffer);
         if (nwrite > 0)
         {
             nbuff   = (*env)->GetByteArrayElements(env, buffer, NULL);
-            ThrowRT_If((nbuff == NULL),
-                env, "native pipe out of memory");
+            if (nbuff == NULL)
+            {
+                ThrowException(env,
+                               "java/lang/RuntimeException",
+                               "native pipe out of memory");
+                break;
+            }
             state   = GOTBUFFER;
+
             (*env)->MonitorExit(env, obj_this);
             /* writing */
             count   = osl_writePipe(npipe, nbuff, nwrite);
-            ThrowRT_If(((*env)->MonitorEnter(env, obj_this) != 0),
-                env, "native pipe cannot synchronize on the object");
-            ThrowIO_If((count != nwrite),
-                env, "native pipe is failed to write");
+            if ((*env)->MonitorEnter(env, obj_this) != 0)
+            {
+                ThrowException(env,
+                               "java/lang/RuntimeException",
+                               "native pipe cannot synchronize on the object");
+                break;
+            }
+            if (count != nwrite)
+            {
+                ThrowException(env,
+                               "com/sun/star/io/IOException",
+                               "native pipe is failed to write");
+                break;
+            }
         }
         /* done */
         (*env)->ReleaseByteArrayElements(env, buffer, nbuff, JNI_ABORT);


Feature: DDS masks now print True or False Cleanup: Remove trailing flag separation characters

--- textureinfo.h
+++ textureinfo.h
@@ -30,6 +30,11 @@
   + (static_cast<std::uint32_t>(C2__) << 16) \
   + (static_cast<std::uint32_t>(C3__) << 24)

+static void RemoveTrailingCharacter(std::string& string, const char character) {
+  const unsigned int end_index(string.size()-1);
+  if(string.at(end_index)==character) string.erase(end_index);
+}
+
 //*-------------------------------
 // Constants
 //-------------------------------*/
@@ -84,6 +89,7 @@
     #define X(a,b) ENUM_APPEND_TO_STRING(a,flag_names)
     #include "defs/pvrLegacy/flags.def"
     #undef X
+    RemoveTrailingCharacter(output,'|');
     return output;
   };
   const std::uint32_t kPixelTypeMask = 0xff;
@@ -548,6 +554,7 @@
     #define X(a,b) ENUM_APPEND_TO_STRING(a,pixel_format_flag_names)
     #include "defs/dds/pixel_format_flags.def"
     #undef X
+    RemoveTrailingCharacter(output,'|');
     return output;
   };
   std::string PrintDDSFlagNames(unsigned int flags) {
@@ -555,6 +562,7 @@
     #define X(a,b) ENUM_APPEND_TO_STRING(a,dds_flag_names)
     #include "defs/dds/dds_flags.def"
     #undef X
+    RemoveTrailingCharacter(output,'|');
     return output;
   };

@@ -616,10 +624,10 @@
     output.push_back(DDSInfo::PrintPixelFormatFlagNames(impl.pixel_format.flags));
     output.push_back(std::to_string(impl.pixel_format.fourcc));
     output.push_back(std::to_string(impl.pixel_format.bit_count));
-    output.push_back(std::to_string(impl.pixel_format.red_mask));
-    output.push_back(std::to_string(impl.pixel_format.blue_mask));
-    output.push_back(std::to_string(impl.pixel_format.green_mask));
-    output.push_back(std::to_string(impl.pixel_format.alpha_mask));
+    output.push_back(impl.pixel_format.red_mask==0?"False":"True");
+    output.push_back(impl.pixel_format.blue_mask==0?"False":"True");
+    output.push_back(impl.pixel_format.green_mask==0?"False":"True");
+    output.push_back(impl.pixel_format.alpha_mask==0?"False":"True");
     output.push_back(std::to_string(impl.size));
     output.push_back(DDSInfo::PrintDDSFlagNames(impl.flags));
     output.push_back(std::to_string(impl.width));
@@ -635,6 +643,7 @@
     for(auto& value: impl.reserved) {
       reserved.append(std::to_string(value) + ':');
     }
+    RemoveTrailingCharacter(reserved,':');
     output.push_back(reserved);
     output.push_back(std::to_string(impl.reserved2));
     // DX 10


net/mlx5: fix crash on GRE flow rule parsing

When set the GRE item, GRE key should follow after GRE header, or the
header gre_item pointer used by the key will be invalid.

Currently in the mlx5_flow_validate_item_gre_key() function, the header
gre_item pointer is access before checking if the key is after the
header or not. Once the key item is before the header, invalid gre_item
pointer access happens.

Move the gre_item pointer access after the GRE header check to avoid the
crash issue.

Fixes: a7a0365565a4 ("net/mlx5: match GRE key and present bits")
Cc: stable@dpdk.org

Signed-off-by: Suanming Mou <ffae22abfb44f67da81795938a64e892585787cc@mellanox.com>
Acked-by: Ori Kam <dd654df5de18ba542acfaea52fe1a0799392087d@mellanox.com>

--- drivers/net/mlx5/mlx5_flow.c
+++ drivers/net/mlx5/mlx5_flow.c
@@ -1998,8 +1998,8 @@
 	const rte_be32_t *mask = item->mask;
 	int ret = 0;
 	rte_be32_t gre_key_default_mask = RTE_BE32(UINT32_MAX);
-	const struct rte_flow_item_gre *gre_spec = gre_item->spec;
-	const struct rte_flow_item_gre *gre_mask = gre_item->mask;
+	const struct rte_flow_item_gre *gre_spec;
+	const struct rte_flow_item_gre *gre_mask;

 	if (item_flags & MLX5_FLOW_LAYER_GRE_KEY)
 		return rte_flow_error_set(error, ENOTSUP,
@@ -2013,8 +2013,10 @@
 		return rte_flow_error_set(error, ENOTSUP,
 					  RTE_FLOW_ERROR_TYPE_ITEM, item,
 					  "GRE key following a wrong item");
+	gre_mask = gre_item->mask;
 	if (!gre_mask)
 		gre_mask = &rte_flow_item_gre_mask;
+	gre_spec = gre_item->spec;
 	if (gre_spec && (gre_mask->c_rsvd0_ver & RTE_BE16(0x2000)) &&
 			 !(gre_spec->c_rsvd0_ver & RTE_BE16(0x2000)))
 		return rte_flow_error_set(error, EINVAL,


net/mlx5: change calculating inline room for Tx

Current implementation is error-prone if the max inline size
(txq->max_inilne) is decoupled from txq->inline_en and becomes zero. If it
becomes zero, HW can crash due to WQ overflow.

Signed-off-by: Yongseok Koh <76b37c91816d73ef9cf709e3e83a68f2d162f1e2@mellanox.com>
Acked-by: Shahaf Shuler <59427d49da6f2b944fbf4cb5ee70ef3ac25f744f@mellanox.com>
Acked-by: Nelio Laranjeiro <2f8dd9032d5b85ca4b53dec8ce664eb6998836be@6wind.com>

--- drivers/net/mlx5/mlx5_rxtx.c
+++ drivers/net/mlx5/mlx5_rxtx.c
@@ -499,6 +499,8 @@
 	unsigned int j = 0;
 	unsigned int k = 0;
 	unsigned int max;
+	unsigned int max_inline = txq->max_inline;
+	const unsigned int inline_en = !!max_inline && txq->inline_en;
 	uint16_t max_wqe;
 	unsigned int comp;
 	volatile struct mlx5_wqe_v *wqe = NULL;
@@ -685,14 +687,14 @@
 			}
 		}
 		/* Inline if enough room. */
-		if (txq->inline_en || tso) {
+		if (inline_en || tso) {
 			uintptr_t end = (uintptr_t)
 				(((uintptr_t)txq->wqes) +
 				 (1 << txq->wqe_n) * MLX5_WQE_SIZE);
-			unsigned int max_inline = txq->max_inline *
-						  RTE_CACHE_LINE_SIZE -
-						  (pkt_inline_sz - 2);
-			uintptr_t addr_end = (addr + max_inline) &
+			unsigned int inline_room = max_inline *
+						   RTE_CACHE_LINE_SIZE -
+						   (pkt_inline_sz - 2);
+			uintptr_t addr_end = (addr + inline_room) &
 					     ~(RTE_CACHE_LINE_SIZE - 1);
 			unsigned int copy_b = (addr_end > addr) ?
 				RTE_MIN((addr_end - addr), length) :


net: phy: fix a bug in get_phy_c45_ids

net: phy: fix a bug in get_phy_c45_ids

When probing devices-in-package for a c45 phy, device zero is the last
device to probe, however, if driver reads 0 from device zero,
c45_ids->devices_in_package is set to '0', the loop condition of probing
will be matched again, see codes below:

for (i = 1;i < num_ids && c45_ids->devices_in_package == 0;i++)

driver will run in a dead loop.

This patch restructures the bug and confusing loop, it provides a helper
function get_phy_c45_devs_in_pkg which to read devices-in-package registers
of a MMD, and rewrites the loop with using the helper function.

Signed-off-by: Shaohui Xie <61f8d37dc3334b2eb149cb87f7fe47d17bf78413@freescale.com>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>


qlge: convert to net_device_ops

qlge: convert to net_device_ops

Convert driver to new net_device_ops. Compile tested only.

Signed-off-by: Stephen Hemminger <a072e933f45880fe04500ea083d5c7f6e81a06f0@vyatta.com>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>

--- drivers/net/qlge/qlge_main.c
+++ drivers/net/qlge/qlge_main.c
@@ -3715,6 +3715,22 @@
 	return err;
 }

+
+static const struct net_device_ops qlge_netdev_ops = {
+	.ndo_open		= qlge_open,
+	.ndo_stop		= qlge_close,
+	.ndo_start_xmit		= qlge_send,
+	.ndo_change_mtu		= qlge_change_mtu,
+	.ndo_get_stats		= qlge_get_stats,
+	.ndo_set_multicast_list = qlge_set_multicast_list,
+	.ndo_set_mac_address	= qlge_set_mac_address,
+	.ndo_validate_addr	= eth_validate_addr,
+	.ndo_tx_timeout		= qlge_tx_timeout,
+	.ndo_vlan_rx_register	= ql_vlan_rx_register,
+	.ndo_vlan_rx_add_vid	= ql_vlan_rx_add_vid,
+	.ndo_vlan_rx_kill_vid	= ql_vlan_rx_kill_vid,
+};
+
 static int __devinit qlge_probe(struct pci_dev *pdev,
 				const struct pci_device_id *pci_entry)
 {
@@ -3752,19 +3768,11 @@
 	 */
 	ndev->tx_queue_len = qdev->tx_ring_size;
 	ndev->irq = pdev->irq;
-	ndev->open = qlge_open;
-	ndev->stop = qlge_close;
-	ndev->hard_start_xmit = qlge_send;
+
+	ndev->netdev_ops = &qlge_netdev_ops;
 	SET_ETHTOOL_OPS(ndev, &qlge_ethtool_ops);
-	ndev->change_mtu = qlge_change_mtu;
-	ndev->get_stats = qlge_get_stats;
-	ndev->set_multicast_list = qlge_set_multicast_list;
-	ndev->set_mac_address = qlge_set_mac_address;
-	ndev->tx_timeout = qlge_tx_timeout;
 	ndev->watchdog_timeo = 10 * HZ;
-	ndev->vlan_rx_register = ql_vlan_rx_register;
-	ndev->vlan_rx_add_vid = ql_vlan_rx_add_vid;
-	ndev->vlan_rx_kill_vid = ql_vlan_rx_kill_vid;
+
 	err = register_netdev(ndev);
 	if (err) {
 		dev_err(&pdev->dev, "net device registration failed.\n");


atmel: Remove open-coded and wrong strcasecmp

The kernel's string library does in fact have strcasecmp, at least
since ded220bd8f08 ("[STRING]: Move strcasecmp/strncasecmp to
lib/string.c"). Moreover, this open-coded version is in fact wrong: If
the strings only differ in their last character, a and b have already
been incremented to point to the terminating NUL bytes, so they would
wrongly be treated as equal.

Signed-off-by: Rasmus Villemoes <ba324ca7b1c77fc20bb970d5aff6eea9377918a5@rasmusvillemoes.dk>
Signed-off-by: Kalle Valo <7081a7d99b8c74c0698a728df19e3915a995d7e1@codeaurora.org>

--- drivers/net/wireless/atmel.c
+++ drivers/net/wireless/atmel.c
@@ -45,7 +45,6 @@
 #include <linux/ptrace.h>
 #include <linux/slab.h>
 #include <linux/string.h>
-#include <linux/ctype.h>
 #include <linux/timer.h>
 #include <asm/byteorder.h>
 #include <asm/io.h>
@@ -2699,16 +2698,7 @@
 		domain[REGDOMAINSZ] = 0;
 		rc = -EINVAL;
 		for (i = 0; i < ARRAY_SIZE(channel_table); i++) {
-			/* strcasecmp doesn't exist in the library */
-			char *a = channel_table[i].name;
-			char *b = domain;
-			while (*a) {
-				char c1 = *a++;
-				char c2 = *b++;
-				if (tolower(c1) != tolower(c2))
-					break;
-			}
-			if (!*a && !*b) {
+			if (!strcasecmp(channel_table[i].name, domain)) {
 				priv->config_reg_domain = channel_table[i].reg_domain;
 				rc = 0;
 			}


mwl8k: get rid of the AMSDU check in the transmit path

Signed-off-by: Lennert Buytenhek <8858498612e3a522354216649776e3032dcb7e5b@marvell.com>
Signed-off-by: John W. Linville <2a53bac7a5d324865ef46ec4c38b2c0fba1456b4@tuxdriver.com>

--- drivers/net/wireless/mwl8k.c
+++ drivers/net/wireless/mwl8k.c
@@ -677,14 +677,6 @@
 	return (qos & qos_mask) | ((ack_policy & val_mask) << shift);
 }

-static inline u16 mwl8k_qos_setbit_amsdu(u16 qos)
-{
-	u16 val_mask = 1 << 7;
-
-	/* AMSDU present Bit 7 */
-	return qos | val_mask;
-}
-
 static inline u16 mwl8k_qos_setbit_qlen(u16 qos, u8 len)
 {
 	u16 val_mask = 0xff;
@@ -1474,9 +1466,6 @@
 		else
 			qos = mwl8k_qos_setbit_ack(qos,
 				MWL8K_TXD_ACK_POLICY_NORMAL);
-
-		if (qos & IEEE80211_QOS_CONTROL_A_MSDU_PRESENT)
-			qos = mwl8k_qos_setbit_amsdu(qos);
 	}

 	dma = pci_map_single(priv->pdev, skb->data,


mwl8k: update MODULE_FIRMWARE tags

mwl8k: update MODULE_FIRMWARE tags

Add MODULE_FIRMWARE tags for the mwl8k firmware images that don't
have them yet, and move them to where the firmware image names are
declared.

Signed-off-by: Lennert Buytenhek <8858498612e3a522354216649776e3032dcb7e5b@marvell.com>
Signed-off-by: John W. Linville <2a53bac7a5d324865ef46ec4c38b2c0fba1456b4@tuxdriver.com>

--- drivers/net/wireless/mwl8k.c
+++ drivers/net/wireless/mwl8k.c
@@ -394,9 +394,6 @@
 	return 0;
 }

-MODULE_FIRMWARE("mwl8k/helper_8687.fw");
-MODULE_FIRMWARE("mwl8k/fmimage_8687.fw");
-
 struct mwl8k_cmd_pkt {
 	__le16	code;
 	__le16	length;
@@ -3737,6 +3734,13 @@
 	},
 };

+MODULE_FIRMWARE("mwl8k/helper_8363.fw");
+MODULE_FIRMWARE("mwl8k/fmimage_8363.fw");
+MODULE_FIRMWARE("mwl8k/helper_8687.fw");
+MODULE_FIRMWARE("mwl8k/fmimage_8687.fw");
+MODULE_FIRMWARE("mwl8k/helper_8366.fw");
+MODULE_FIRMWARE("mwl8k/fmimage_8366.fw");
+
 static DEFINE_PCI_DEVICE_TABLE(mwl8k_pci_id_table) = {
 	{ PCI_VDEVICE(MARVELL, 0x2a0c), .driver_data = MWL8363, },
 	{ PCI_VDEVICE(MARVELL, 0x2a24), .driver_data = MWL8363, },


mwl8k: Do not expire eapol frames

mwl8k: Do not expire eapol frames

This can cause issues when clients try to connect when the
traffic is heavy

Signed-off-by: Nishant Sarmukadam <71b9d35293bd317f79504bc5dacd7f99836f2319@marvell.com>
Signed-off-by: John W. Linville <2a53bac7a5d324865ef46ec4c38b2c0fba1456b4@tuxdriver.com>

--- drivers/net/wireless/mwl8k.c
+++ drivers/net/wireless/mwl8k.c
@@ -1851,12 +1851,16 @@
 	bool start_ba_session = false;
 	bool mgmtframe = false;
 	struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)skb->data;
+	bool eapol_frame = false;

 	wh = (struct ieee80211_hdr *)skb->data;
 	if (ieee80211_is_data_qos(wh->frame_control))
 		qos = le16_to_cpu(*((__le16 *)ieee80211_get_qos_ctl(wh)));
 	else
 		qos = 0;
+
+	if (skb->protocol == cpu_to_be16(ETH_P_PAE))
+		eapol_frame = true;

 	if (ieee80211_is_mgmt(wh->frame_control))
 		mgmtframe = true;
@@ -1916,9 +1920,8 @@

 	txpriority = index;

-	if (priv->ap_fw && sta && sta->ht_cap.ht_supported
-			&& skb->protocol != cpu_to_be16(ETH_P_PAE)
-			&& ieee80211_is_data_qos(wh->frame_control)) {
+	if (priv->ap_fw && sta && sta->ht_cap.ht_supported && !eapol_frame &&
+	    ieee80211_is_data_qos(wh->frame_control)) {
 		tid = qos & 0xf;
 		mwl8k_tx_count_packet(sta, tid);
 		spin_lock(&priv->stream_lock);
@@ -2027,7 +2030,7 @@
 	else
 		tx->peer_id = 0;

-	if (priv->ap_fw)
+	if (priv->ap_fw && ieee80211_is_data(wh->frame_control) && !eapol_frame)
 		tx->timestamp = cpu_to_le32(ioread32(priv->regs +
 						MWL8K_HW_TIMER_REGISTER));


PCI: mvebu: Remove redundant of_match_ptr

mvebu_pcie_of_match_table is always compiled in.  Hence of_match_ptr is not
required.

Signed-off-by: Sachin Kamat <1c3b1584a6008857f36c03c58f657c0fc16fc09e@linaro.org>
Signed-off-by: Bjorn Helgaas <f10ec01be0c6b54271af5c550cd257810bdf3268@google.com>
Acked-by: Thomas Petazzoni <a5d87d2bd7c424ee5cbdb4e978635bf653d5a005@free-electrons.com>

--- drivers/pci/host/pci-mvebu.c
+++ drivers/pci/host/pci-mvebu.c
@@ -1007,8 +1007,7 @@
 	.driver = {
 		.owner = THIS_MODULE,
 		.name = "mvebu-pcie",
-		.of_match_table =
-		   of_match_ptr(mvebu_pcie_of_match_table),
+		.of_match_table = mvebu_pcie_of_match_table,
 		/* driver unloading/unbinding currently not supported */
 		.suppress_bind_attrs = true,
 	},


upgrade to WebRTC M87

upgrade to WebRTC M87

error: pathspec 'lib/WebRTC.framework/Headers/RTCNetworkMonitor.h' did not match any file(s) known to git

--- lib/WebRTC.framework/Headers/RTCNetworkMonitor.h
+++ lib/WebRTC.framework/Headers/RTCNetworkMonitor.h
@@ -0,0 +1,24 @@
+/*
+ *  Copyright 2020 The WebRTC Project Authors. All rights reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+#import <Foundation/Foundation.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+/** Listens for NWPathMonitor updates and forwards the results to a C++
+ *  observer.
+ */
+@interface RTCNetworkMonitor : NSObject
+
+- (instancetype)init NS_UNAVAILABLE;
+
+@end
+
+NS_ASSUME_NONNULL_END


PCI: mvebu: Use of_get_available_child_count()

Rather than open-coding of_get_available_child_count(), use the provided
helper instead.

Tested-by: Thomas Petazzoni <a5d87d2bd7c424ee5cbdb4e978635bf653d5a005@free-electrons.com> (Armada XP GP)
Tested-by: Andrew Lunn <02e0a999c50b1f88df7a8f5a04e1b76b35ea6a88@lunn.ch> (Kirkwood DIR665)
Signed-off-by: Russell King <f6aa0246ff943bfa8602cdf60d40c481b38ed232@arm.linux.org.uk>
Signed-off-by: Bjorn Helgaas <f10ec01be0c6b54271af5c550cd257810bdf3268@google.com>
Reviewed-by: Thomas Petazzoni <a5d87d2bd7c424ee5cbdb4e978635bf653d5a005@free-electrons.com>

--- drivers/pci/host/pci-mvebu.c
+++ drivers/pci/host/pci-mvebu.c
@@ -933,7 +933,7 @@
 	struct mvebu_pcie *pcie;
 	struct device_node *np = pdev->dev.of_node;
 	struct device_node *child;
-	int i, ret;
+	int num, i, ret;

 	pcie = devm_kzalloc(&pdev->dev, sizeof(struct mvebu_pcie),
 			    GFP_KERNEL);
@@ -969,14 +969,9 @@
 		return ret;
 	}

-	i = 0;
-	for_each_child_of_node(pdev->dev.of_node, child) {
-		if (!of_device_is_available(child))
-			continue;
-		i++;
-	}
-
-	pcie->ports = devm_kzalloc(&pdev->dev, i *
+	num = of_get_available_child_count(pdev->dev.of_node);
+
+	pcie->ports = devm_kzalloc(&pdev->dev, num *
 				   sizeof(struct mvebu_pcie_port),
 				   GFP_KERNEL);
 	if (!pcie->ports)