void data_allocate(int i, int j, int k) { a_err istat = 0; //Reduction sum istat = meta_alloc(&reduction, g_typesize); printf("Status (Sum alloc):\t%d\n", istat); //3D region data3 = malloc(g_typesize * i * j * k); istat = meta_alloc(&dev_data3, g_typesize * i * j * k); printf("Status (3D alloc):\t%d\n", istat); //North/south faces face[0] = malloc(g_typesize * i * j); face[1] = malloc(g_typesize * i * j); istat = meta_alloc(&dev_face[0], g_typesize * i * j); istat |= meta_alloc(&dev_face[1], g_typesize * i * j); printf("Status (N/S faces):\t%d\n", istat); //East/west faces face[2] = malloc(g_typesize * j * k); face[3] = malloc(g_typesize * j * k); istat = meta_alloc(&dev_face[2], g_typesize * j * k); istat |= meta_alloc(&dev_face[3], g_typesize * j * k); printf("Status (E/W faces):\t%d\n", istat); //Top/bottom faces face[4] = malloc(g_typesize * i * k); face[5] = malloc(g_typesize * i * k); istat = meta_alloc(&dev_face[4], g_typesize * i * k); istat |= meta_alloc(&dev_face[5], g_typesize * i * k); printf("Status (T/B faces):\t%d\n", istat); printf("Data Allocated\n"); }
static int meta_parse(struct rtnl_ematch *e, void *data, size_t len) { struct meta_data *m = rtnl_ematch_data(e); struct nlattr *tb[TCA_EM_META_MAX+1]; struct rtnl_meta_value *v; struct tcf_meta_hdr *hdr; void *vdata = NULL; size_t vlen = 0; int err; if ((err = nla_parse(tb, TCA_EM_META_MAX, data, len, meta_policy)) < 0) return err; if (!tb[TCA_EM_META_HDR]) return -NLE_MISSING_ATTR; hdr = nla_data(tb[TCA_EM_META_HDR]); if (tb[TCA_EM_META_LVALUE]) { vdata = nla_data(tb[TCA_EM_META_LVALUE]); vlen = nla_len(tb[TCA_EM_META_LVALUE]); } v = meta_alloc(TCF_META_TYPE(hdr->left.kind), TCF_META_ID(hdr->left.kind), hdr->left.shift, vdata, vlen); if (!v) return -NLE_NOMEM; m->left = v; vlen = 0; if (tb[TCA_EM_META_RVALUE]) { vdata = nla_data(tb[TCA_EM_META_RVALUE]); vlen = nla_len(tb[TCA_EM_META_RVALUE]); } v = meta_alloc(TCF_META_TYPE(hdr->right.kind), TCF_META_ID(hdr->right.kind), hdr->right.shift, vdata, vlen); if (!v) { rtnl_meta_value_put(m->left); return -NLE_NOMEM; } m->right = v; m->opnd = hdr->left.op; return 0; }
struct rtnl_meta_value *rtnl_meta_value_alloc_id(uint8_t type, uint16_t id, uint8_t shift, uint64_t mask) { size_t masklen = 0; if (id > TCF_META_ID_MAX) return NULL; if (mask) { if (type == TCF_META_TYPE_VAR) return NULL; masklen = 8; } return meta_alloc(type, id, shift, &mask, masklen); }
struct rtnl_meta_value *rtnl_meta_value_alloc_var(void *data, size_t len) { return meta_alloc(TCF_META_TYPE_VAR, TCF_META_ID_VALUE, 0, data, len); }
struct rtnl_meta_value *rtnl_meta_value_alloc_int(uint64_t value) { return meta_alloc(TCF_META_TYPE_INT, TCF_META_ID_VALUE, 0, &value, 8); }