summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniele Di Proietto <diproiettod@vmware.com>2015-05-22 17:14:19 +0100
committerEthan Jackson <ethan@nicira.com>2015-05-22 11:28:19 -0700
commitbd5131ba76156cac4f00d4ace3cdcb31d9135d11 (patch)
tree63d0eeb7898519a4c4391b4cabd2cca0d26a59db /lib
parentb940b3d79367b3661479367399e353dabcf9c569 (diff)
downloadopenvswitch-bd5131ba76156cac4f00d4ace3cdcb31d9135d11.tar.gz
ovs-numa: Change 'core_id' to unsigned.
DPDK lcore_id is unsigned. We need to support big values like LCORE_ID_ANY (=UINT32_MAX). Therefore I am changing the type everywhere in OVS. Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com> Signed-off-by: Ethan Jackson <ethan@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/dpif-netdev.c27
-rw-r--r--lib/dpif.c6
-rw-r--r--lib/dpif.h16
-rw-r--r--lib/netdev-dpdk.c4
-rw-r--r--lib/netdev-dpdk.h4
-rw-r--r--lib/ovs-numa.c20
-rw-r--r--lib/ovs-numa.h30
7 files changed, 55 insertions, 52 deletions
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 22fba7e6d..ace5cb552 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -295,7 +295,7 @@ struct dp_netdev_flow {
const struct cmap_node node; /* In owning dp_netdev_pmd_thread's */
/* 'flow_table'. */
const ovs_u128 ufid; /* Unique flow identifier. */
- const int pmd_id; /* The 'core_id' of pmd thread owning this */
+ const unsigned pmd_id; /* The 'core_id' of pmd thread owning this */
/* flow. */
/* Number of references.
@@ -413,7 +413,7 @@ struct dp_netdev_pmd_thread {
pthread_t thread;
int index; /* Idx of this pmd thread among pmd*/
/* threads on same numa node. */
- int core_id; /* CPU core id of this pmd thread. */
+ unsigned core_id; /* CPU core id of this pmd thread. */
int numa_id; /* numa node id of this pmd thread. */
/* Only a pmd thread can write on its own 'cycles' and 'stats'.
@@ -458,11 +458,11 @@ static void dp_netdev_disable_upcall(struct dp_netdev *);
void dp_netdev_pmd_reload_done(struct dp_netdev_pmd_thread *pmd);
static void dp_netdev_configure_pmd(struct dp_netdev_pmd_thread *pmd,
struct dp_netdev *dp, int index,
- int core_id, int numa_id);
+ unsigned core_id, int numa_id);
static void dp_netdev_destroy_pmd(struct dp_netdev_pmd_thread *pmd);
static void dp_netdev_set_nonpmd(struct dp_netdev *dp);
static struct dp_netdev_pmd_thread *dp_netdev_get_pmd(struct dp_netdev *dp,
- int core_id);
+ unsigned core_id);
static struct dp_netdev_pmd_thread *
dp_netdev_pmd_get_next(struct dp_netdev *dp, struct cmap_position *pos);
static void dp_netdev_destroy_all_pmds(struct dp_netdev *dp);
@@ -581,7 +581,7 @@ pmd_info_show_stats(struct ds *reply,
ds_put_format(reply, " numa_id %d", pmd->numa_id);
}
if (pmd->core_id != OVS_CORE_UNSPEC) {
- ds_put_format(reply, " core_id %d", pmd->core_id);
+ ds_put_format(reply, " core_id %u", pmd->core_id);
}
ds_put_cstr(reply, ":\n");
@@ -1942,7 +1942,8 @@ dpif_netdev_flow_get(const struct dpif *dpif, const struct dpif_flow_get *get)
struct dp_netdev *dp = get_dp_netdev(dpif);
struct dp_netdev_flow *netdev_flow;
struct dp_netdev_pmd_thread *pmd;
- int pmd_id = get->pmd_id == PMD_ID_NULL ? NON_PMD_CORE_ID : get->pmd_id;
+ unsigned pmd_id = get->pmd_id == PMD_ID_NULL
+ ? NON_PMD_CORE_ID : get->pmd_id;
int error = 0;
pmd = dp_netdev_get_pmd(dp, pmd_id);
@@ -1982,7 +1983,7 @@ dp_netdev_flow_add(struct dp_netdev_pmd_thread *pmd,
memset(&flow->stats, 0, sizeof flow->stats);
flow->dead = false;
flow->batch = NULL;
- *CONST_CAST(int *, &flow->pmd_id) = pmd->core_id;
+ *CONST_CAST(unsigned *, &flow->pmd_id) = pmd->core_id;
*CONST_CAST(struct flow *, &flow->flow) = match->flow;
*CONST_CAST(ovs_u128 *, &flow->ufid) = *ufid;
ovs_refcount_init(&flow->ref_cnt);
@@ -2025,7 +2026,8 @@ dpif_netdev_flow_put(struct dpif *dpif, const struct dpif_flow_put *put)
struct dp_netdev_pmd_thread *pmd;
struct match match;
ovs_u128 ufid;
- int pmd_id = put->pmd_id == PMD_ID_NULL ? NON_PMD_CORE_ID : put->pmd_id;
+ unsigned pmd_id = put->pmd_id == PMD_ID_NULL
+ ? NON_PMD_CORE_ID : put->pmd_id;
int error;
error = dpif_netdev_flow_from_nlattrs(put->key, put->key_len, &match.flow);
@@ -2120,7 +2122,8 @@ dpif_netdev_flow_del(struct dpif *dpif, const struct dpif_flow_del *del)
struct dp_netdev *dp = get_dp_netdev(dpif);
struct dp_netdev_flow *netdev_flow;
struct dp_netdev_pmd_thread *pmd;
- int pmd_id = del->pmd_id == PMD_ID_NULL ? NON_PMD_CORE_ID : del->pmd_id;
+ unsigned pmd_id = del->pmd_id == PMD_ID_NULL
+ ? NON_PMD_CORE_ID : del->pmd_id;
int error = 0;
pmd = dp_netdev_get_pmd(dp, pmd_id);
@@ -2745,7 +2748,7 @@ dp_netdev_pmd_reload_done(struct dp_netdev_pmd_thread *pmd)
*
* Caller must unrefs the returned reference. */
static struct dp_netdev_pmd_thread *
-dp_netdev_get_pmd(struct dp_netdev *dp, int core_id)
+dp_netdev_get_pmd(struct dp_netdev *dp, unsigned core_id)
{
struct dp_netdev_pmd_thread *pmd;
const struct cmap_node *pnode;
@@ -2808,7 +2811,7 @@ dp_netdev_pmd_get_next(struct dp_netdev *dp, struct cmap_position *pos)
/* Configures the 'pmd' based on the input argument. */
static void
dp_netdev_configure_pmd(struct dp_netdev_pmd_thread *pmd, struct dp_netdev *dp,
- int index, int core_id, int numa_id)
+ int index, unsigned core_id, int numa_id)
{
pmd->dp = dp;
pmd->index = index;
@@ -2921,7 +2924,7 @@ dp_netdev_set_pmds_on_numa(struct dp_netdev *dp, int numa_id)
can_have = dp->pmd_cmask ? n_unpinned : MIN(n_unpinned, NR_PMD_THREADS);
for (i = 0; i < can_have; i++) {
struct dp_netdev_pmd_thread *pmd = xzalloc(sizeof *pmd);
- int core_id = ovs_numa_get_unpinned_core_on_numa(numa_id);
+ unsigned core_id = ovs_numa_get_unpinned_core_on_numa(numa_id);
dp_netdev_configure_pmd(pmd, dp, i, core_id, numa_id);
/* Each thread will distribute all devices rx-queues among
diff --git a/lib/dpif.c b/lib/dpif.c
index b8f30a503..aa5e64e3f 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -917,7 +917,7 @@ dpif_probe_feature(struct dpif *dpif, const char *name,
int
dpif_flow_get(struct dpif *dpif,
const struct nlattr *key, size_t key_len, const ovs_u128 *ufid,
- const int pmd_id, struct ofpbuf *buf, struct dpif_flow *flow)
+ const unsigned pmd_id, struct ofpbuf *buf, struct dpif_flow *flow)
{
struct dpif_op *opp;
struct dpif_op op;
@@ -946,7 +946,7 @@ dpif_flow_put(struct dpif *dpif, enum dpif_flow_put_flags flags,
const struct nlattr *key, size_t key_len,
const struct nlattr *mask, size_t mask_len,
const struct nlattr *actions, size_t actions_len,
- const ovs_u128 *ufid, const int pmd_id,
+ const ovs_u128 *ufid, const unsigned pmd_id,
struct dpif_flow_stats *stats)
{
struct dpif_op *opp;
@@ -974,7 +974,7 @@ dpif_flow_put(struct dpif *dpif, enum dpif_flow_put_flags flags,
int
dpif_flow_del(struct dpif *dpif,
const struct nlattr *key, size_t key_len, const ovs_u128 *ufid,
- const int pmd_id, struct dpif_flow_stats *stats)
+ const unsigned pmd_id, struct dpif_flow_stats *stats)
{
struct dpif_op *opp;
struct dpif_op op;
diff --git a/lib/dpif.h b/lib/dpif.h
index 06c652558..ba5d59763 100644
--- a/lib/dpif.h
+++ b/lib/dpif.h
@@ -525,15 +525,15 @@ int dpif_flow_put(struct dpif *, enum dpif_flow_put_flags,
const struct nlattr *key, size_t key_len,
const struct nlattr *mask, size_t mask_len,
const struct nlattr *actions, size_t actions_len,
- const ovs_u128 *ufid, const int pmd_id,
+ const ovs_u128 *ufid, const unsigned pmd_id,
struct dpif_flow_stats *);
int dpif_flow_del(struct dpif *,
const struct nlattr *key, size_t key_len,
- const ovs_u128 *ufid, const int pmd_id,
+ const ovs_u128 *ufid, const unsigned pmd_id,
struct dpif_flow_stats *);
int dpif_flow_get(struct dpif *,
const struct nlattr *key, size_t key_len,
- const ovs_u128 *ufid, const int pmd_id,
+ const ovs_u128 *ufid, const unsigned pmd_id,
struct ofpbuf *, struct dpif_flow *);
/* Flow dumping interface
@@ -583,7 +583,7 @@ struct dpif_flow {
size_t actions_len; /* 'actions' length in bytes. */
ovs_u128 ufid; /* Unique flow identifier. */
bool ufid_present; /* True if 'ufid' was provided by datapath.*/
- int pmd_id; /* Datapath poll mode dirver id. */
+ unsigned pmd_id; /* Datapath poll mode driver id. */
struct dpif_flow_stats stats; /* Flow statistics. */
};
int dpif_flow_dump_next(struct dpif_flow_dump_thread *,
@@ -640,7 +640,7 @@ struct dpif_flow_put {
const struct nlattr *actions; /* Actions to perform on flow. */
size_t actions_len; /* Length of 'actions' in bytes. */
const ovs_u128 *ufid; /* Optional unique flow identifier. */
- int pmd_id; /* Datapath poll mode driver id. */
+ unsigned pmd_id; /* Datapath poll mode driver id. */
/* Output. */
struct dpif_flow_stats *stats; /* Optional flow statistics. */
@@ -671,7 +671,7 @@ struct dpif_flow_del {
const ovs_u128 *ufid; /* Unique identifier of flow to delete. */
bool terse; /* OK to skip sending/receiving full flow
* info? */
- int pmd_id; /* Datapath poll mode driver id. */
+ unsigned pmd_id; /* Datapath poll mode driver id. */
/* Output. */
struct dpif_flow_stats *stats; /* Optional flow statistics. */
@@ -732,7 +732,7 @@ struct dpif_flow_get {
const struct nlattr *key; /* Flow to get. */
size_t key_len; /* Length of 'key' in bytes. */
const ovs_u128 *ufid; /* Unique identifier of flow to get. */
- int pmd_id; /* Datapath poll mode driver id. */
+ unsigned pmd_id; /* Datapath poll mode driver id. */
struct ofpbuf *buffer; /* Storage for output parameters. */
/* Output. */
@@ -807,7 +807,7 @@ struct dpif_upcall {
typedef int upcall_callback(const struct dp_packet *packet,
const struct flow *flow,
ovs_u128 *ufid,
- int pmd_id,
+ unsigned pmd_id,
enum dpif_upcall_type type,
const struct nlattr *userdata,
struct ofpbuf *actions,
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 02a003280..a4868ccc1 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -478,7 +478,7 @@ netdev_dpdk_alloc(void)
static void
netdev_dpdk_alloc_txq(struct netdev_dpdk *netdev, unsigned int n_txqs)
{
- int i;
+ unsigned i;
netdev->tx_q = dpdk_rte_mzalloc(n_txqs * sizeof *netdev->tx_q);
/* Each index is considered as a cpu core id, since there should
@@ -1993,7 +1993,7 @@ netdev_dpdk_register(void)
}
int
-pmd_thread_setaffinity_cpu(int cpu)
+pmd_thread_setaffinity_cpu(unsigned cpu)
{
cpu_set_t cpuset;
int err;
diff --git a/lib/netdev-dpdk.h b/lib/netdev-dpdk.h
index d3840f97c..2924f2330 100644
--- a/lib/netdev-dpdk.h
+++ b/lib/netdev-dpdk.h
@@ -28,7 +28,7 @@ struct dp_packet;
int dpdk_init(int argc, char **argv);
void netdev_dpdk_register(void);
void free_dpdk_buf(struct dp_packet *);
-int pmd_thread_setaffinity_cpu(int cpu);
+int pmd_thread_setaffinity_cpu(unsigned cpu);
void thread_set_nonpmd(void);
#else
@@ -57,7 +57,7 @@ free_dpdk_buf(struct dp_packet *buf OVS_UNUSED)
}
static inline int
-pmd_thread_setaffinity_cpu(int cpu OVS_UNUSED)
+pmd_thread_setaffinity_cpu(unsigned cpu OVS_UNUSED)
{
return 0;
}
diff --git a/lib/ovs-numa.c b/lib/ovs-numa.c
index 5bed2b5e2..693541fe7 100644
--- a/lib/ovs-numa.c
+++ b/lib/ovs-numa.c
@@ -70,7 +70,7 @@ struct cpu_core {
struct hmap_node hmap_node;/* In the 'all_cpu_cores'. */
struct ovs_list list_node; /* In 'numa_node->cores' list. */
struct numa_node *numa; /* numa node containing the core. */
- int core_id; /* Core id. */
+ unsigned core_id; /* Core id. */
bool available; /* If the core can be pinned. */
bool pinned; /* If a thread has been pinned to the core. */
};
@@ -118,7 +118,7 @@ discover_numa_and_core(void)
if (!strncmp(subdir->d_name, "cpu", 3)
&& contain_all_digits(subdir->d_name + 3)){
struct cpu_core *c = xzalloc(sizeof *c);
- uint32_t core_id;
+ unsigned core_id;
core_id = strtoul(subdir->d_name + 3, NULL, 10);
hmap_insert(&all_cpu_cores, &c->hmap_node,
@@ -153,7 +153,7 @@ discover_numa_and_core(void)
/* Gets 'struct cpu_core' by 'core_id'. */
static struct cpu_core*
-get_core_by_core_id(int core_id)
+get_core_by_core_id(unsigned core_id)
{
struct cpu_core *core = NULL;
@@ -201,13 +201,13 @@ ovs_numa_numa_id_is_valid(int numa_id)
}
bool
-ovs_numa_core_id_is_valid(int core_id)
+ovs_numa_core_id_is_valid(unsigned core_id)
{
return found_numa_and_core && core_id < ovs_numa_get_n_cores();
}
bool
-ovs_numa_core_is_pinned(int core_id)
+ovs_numa_core_is_pinned(unsigned core_id)
{
struct cpu_core *core = get_core_by_core_id(core_id);
@@ -237,7 +237,7 @@ ovs_numa_get_n_cores(void)
/* Given 'core_id', returns the corresponding numa node id. Returns
* OVS_NUMA_UNSPEC if 'core_id' is invalid. */
int
-ovs_numa_get_numa_id(int core_id)
+ovs_numa_get_numa_id(unsigned core_id)
{
struct cpu_core *core = get_core_by_core_id(core_id);
@@ -288,7 +288,7 @@ ovs_numa_get_n_unpinned_cores_on_numa(int numa_id)
* False, if the core has already been pinned, or if it is invalid or
* not available. */
bool
-ovs_numa_try_pin_core_specific(int core_id)
+ovs_numa_try_pin_core_specific(unsigned core_id)
{
struct cpu_core *core = get_core_by_core_id(core_id);
@@ -305,7 +305,7 @@ ovs_numa_try_pin_core_specific(int core_id)
/* Searches through all cores for an unpinned and available core. Returns
* the 'core_id' if found and sets the 'core->pinned' to true. Otherwise,
* returns OVS_CORE_UNSPEC. */
-int
+unsigned
ovs_numa_get_unpinned_core_any(void)
{
struct cpu_core *core;
@@ -323,7 +323,7 @@ ovs_numa_get_unpinned_core_any(void)
/* Searches through all cores on numa node with 'numa_id' for an
* unpinned and available core. Returns the core_id if found and
* sets the 'core->pinned' to true. Otherwise, returns OVS_CORE_UNSPEC. */
-int
+unsigned
ovs_numa_get_unpinned_core_on_numa(int numa_id)
{
struct numa_node *numa = get_numa_by_numa_id(numa_id);
@@ -344,7 +344,7 @@ ovs_numa_get_unpinned_core_on_numa(int numa_id)
/* Unpins the core with 'core_id'. */
void
-ovs_numa_unpin_core(int core_id)
+ovs_numa_unpin_core(unsigned core_id)
{
struct cpu_core *core = get_core_by_core_id(core_id);
diff --git a/lib/ovs-numa.h b/lib/ovs-numa.h
index 35b351bfb..1435d3d97 100644
--- a/lib/ovs-numa.h
+++ b/lib/ovs-numa.h
@@ -35,25 +35,25 @@ struct ovs_numa_dump {
struct ovs_numa_info {
struct ovs_list list_node;
int numa_id;
- int core_id;
+ unsigned core_id;
};
#ifdef __linux__
void ovs_numa_init(void);
bool ovs_numa_numa_id_is_valid(int numa_id);
-bool ovs_numa_core_id_is_valid(int core_id);
-bool ovs_numa_core_is_pinned(int core_id);
+bool ovs_numa_core_id_is_valid(unsigned core_id);
+bool ovs_numa_core_is_pinned(unsigned core_id);
int ovs_numa_get_n_numas(void);
void ovs_numa_set_cpu_mask(const char *cmask);
int ovs_numa_get_n_cores(void);
-int ovs_numa_get_numa_id(int core_id);
+int ovs_numa_get_numa_id(unsigned core_id);
int ovs_numa_get_n_cores_on_numa(int numa_id);
int ovs_numa_get_n_unpinned_cores_on_numa(int numa_id);
-bool ovs_numa_try_pin_core_specific(int core_id);
-int ovs_numa_get_unpinned_core_any(void);
-int ovs_numa_get_unpinned_core_on_numa(int numa_id);
-void ovs_numa_unpin_core(int core_id);
+bool ovs_numa_try_pin_core_specific(unsigned core_id);
+unsigned ovs_numa_get_unpinned_core_any(void);
+unsigned ovs_numa_get_unpinned_core_on_numa(int numa_id);
+void ovs_numa_unpin_core(unsigned core_id);
struct ovs_numa_dump *ovs_numa_dump_cores_on_numa(int numa_id);
void ovs_numa_dump_destroy(struct ovs_numa_dump *);
@@ -75,13 +75,13 @@ ovs_numa_numa_id_is_valid(int numa_id OVS_UNUSED)
}
static inline bool
-ovs_numa_core_id_is_valid(int core_id OVS_UNUSED)
+ovs_numa_core_id_is_valid(unsigned core_id OVS_UNUSED)
{
return false;
}
static inline bool
-ovs_numa_core_is_pinned(int core_id OVS_UNUSED)
+ovs_numa_core_is_pinned(unsigned core_id OVS_UNUSED)
{
return false;
}
@@ -105,7 +105,7 @@ ovs_numa_get_n_cores(void)
}
static inline int
-ovs_numa_get_numa_id(int core_id OVS_UNUSED)
+ovs_numa_get_numa_id(unsigned core_id OVS_UNUSED)
{
return OVS_NUMA_UNSPEC;
}
@@ -123,25 +123,25 @@ ovs_numa_get_n_unpinned_cores_on_numa(int numa_id OVS_UNUSED)
}
static inline bool
-ovs_numa_try_pin_core_specific(int core_id OVS_UNUSED)
+ovs_numa_try_pin_core_specific(unsigned core_id OVS_UNUSED)
{
return false;
}
-static inline int
+static inline unsigned
ovs_numa_get_unpinned_core_any(void)
{
return OVS_CORE_UNSPEC;
}
-static inline int
+static inline unsigned
ovs_numa_get_unpinned_core_on_numa(int numa_id OVS_UNUSED)
{
return OVS_CORE_UNSPEC;
}
static inline void
-ovs_numa_unpin_core(int core_id OVS_UNUSED)
+ovs_numa_unpin_core(unsigned core_id OVS_UNUSED)
{
/* Nothing */
}